Serving APIs with Express

In this section, you’ll develop a minimal Hello World application using Express to cover the basics, then we’ll move on to something more substantial. Since this project will be short-lived, we won’t bother with creating a package.json file.

To begin, create a directory called hello to hold the application, and open a terminal to this directory. Next, install Express and Morgan (a logging utility).

​ ​$ ​​npm​​ ​​install​​ ​​express@4.14.1​​ ​​morgan@1.8.1​

With those modules installed, open a text editor and enter the following:

​ ​'use strict'​;
​ ​const​ express = require(​'express'​);
​ ​const​ morgan = require(​'morgan' ...

Get Node.js 8 the Right Way now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.