Table of contents
- 1. Writing custom Express middleware
You can extend your Express.js server easily with custom middleware. All you have to do is to write a function that accepts three parameters (
Writing custom Express middleware
By writing a function that follows the
ApplicationRequestHandler type of Express.js, you can extend your app server with custom functionality.
A “middleware” in Express is just a function that intercepts every request so that you can return a custom response or apply a custom filter when a request reaches your server. You can also call the
next function to pass on the request for processing (to another registered middleware).