August 2017
Beginner
374 pages
10h 41m
English
The HTTP library, express, allows us to extend the server by executing middleware on every request; for example, consider this:
const app = express()function middlewareFn (req, res, next) { console.log('requested url:', req.originalUrl) next()}app.use(middlewareFn)
The preceding middleware function logs the requested URL for each request, then continues with the rest of the request. If we want our middleware to reject the request, we can simply throw an error instead of calling next().
Read now
Unlock full access