Now, We’ll understand the role and usage of Node.js and why you use it and what you use it for. So, you use Node.js to run it on a server to write server-side code.
Then, they visit a page, example.com and they send a request to do. so, for example, by entering a URL in the browser, a request sent to that URL.
Now, the server comes into play. So, we got our server. so, some computer running on the Internet which has the IP associated with that domain which is automatically resolved for us and on that server. then, we want to execute some code that does something with the incoming request and returns a response. often but not necessarily always as you will learn. this response is an HTML page which the browser then, in turn, can display.
Now, on the server, We connect to databases, for example, to fetch and store data. We do user authentication which we can only do on a place the user can’t access to make it more secure and avoid it being hacked.
We do it for input validation to see if a user entered a correct e-mail address, And in general, we have our business logic on the server.
Nodejs gives us and this is how we allow our users to work with the server through that request and response pattern, the direct access is not available.
you actually used Nodejs indirectly a lot for all the build processes. these languages or frameworks needed because Nodejs is a great tool for writing utility scripts. You have access to the file system. so you can write and read and manipulate files and this allows you to do a lot of utility stuff on your computer that is never exposed to the public.
In general and that is the most popular thing you do with Nodejs though, you use it in the context of web development and server-side code.
So, you use it to run a server for example, with Nodejs you don’t write the code that is running on your server. you also write the server yourself, so the code that takes the incoming requests and routes them to your well other code.