Express - martinbalke-401-adavanced-js/seattle-javascript-401n14 GitHub Wiki

Express Middleware

The thing that makes Express such a powerful library is it's ability to use middleware. On it's own Express does not have much functionality it uses middleware to achieve most tasks. Middleware can be defined as a function that runs with the request, response, and next parameters. It is run in between a call to a url and the final response back from that call, modifying the data along the way.

There are two main ways to set up express to use middleware. You can declare a global middleware by defining app.use('somemiddleware'); or you can define a middleware for a specific route by adding it as a parameter for that route such as app.get('/', somemiddleware, (res, req) => {});