Empowering Express with middlewares

In Chapter 1, What is Express?, we learned about Express middlewares and saw how to create one. Now, let's go find out how to include one in our app. Remember we use app.use() for including middlewares.

Though we can write our own middlewares, we will focus on using one of the middlewares that comes bundled with Express.

For your reference, the following is the list of the middlewares that are available in Express, by default:

Middleware

Description

router

The app's routing system

logger

Log requests to the server

compress

gzip/deflate support on the server

basicAuth

Basic HTTP authentication

json

Parse application/ json

urlencoded

Parse application/x-www-form-urlencoded

multipart ...

Get Express Web Application Development 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.