Whenever you write a Node app, you always need to start somewhere. The typical convention while building servers with Node is that you have a single
server.js file located within the root of your project. This file will boot up the server and start the whole process. In our case, this is the file that will create the HTTP server and listen for all HTTP events, which is ultimately the point of our entire application.
We are going to keep our
server.js pretty lean so that its contents are very self-explanatory. Any major logic that is going to be executed within this file will actually be defered to external modules hosted within other files.
Before we can do anything within
server.js, we need to require a few modules ...