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.