- MERN Quick Start Guide
- Eddy Wilson Iriarte Koroliova
- 77字
- 2021-06-25 21:30:14
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.