02 / 04

How do we apply middleware to routes?

Middleware can be applied either to all routes or to particular ones:

Every time the app receives a request, middleware logger is called
Attach Middleware to a Specific Route, When defining the route, pass your middleware function as an argument before the final route handler function. This means that whenever a request is made to that route, your middleware runs first.