Working with Middleware
Azat Mardan · Apress eBooks · 2014
Middleware is an amazingly useful pattern that allows developers to reuse code within their applications and even share it with others in the form of NPM modules. The essential definition of middleware is a function with three arguments: request (or req ), response ( res ), and next . If you’re writing your own middleware, you can use arbitrary names for arguments, but it’s better to stick to the common naming convention. Here’s an example of how to define your own middleware: These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.