Writing configurable middleware functions

A common pattern for writing middleware functions is to wrap the middleware function inside another function. The result of doing so is a configurable middleware function. They are also higher-order functions, that is, a function that returns another function.

const fn = (options) => (response, request, next) => {  
    next()  
} 

Usually an object is used as an options parameters. However, there is nothing stopping you from doing it in your own way.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.140.245.196