In order to deliver web content, we need to make a Uniform Resource Identifier (URI) available. This recipe walks us through the creation of an HTTP server that exposes routes to the user.
First let's create our server file. If our main purpose is to expose server functionality, it's a general practice to call the
server.js file (because the
npm start command runs the
node server.js command by default). We could put this new
server.js file in a new folder.
It's also a good idea to install and use
supervisor. We use
npm (the module downloading and publishing command-line application that ships with Node) to install. On the command-line utility, we write the following command:
sudo npm -g install supervisor