topic : understanding how to add custom parameters in Express middleware
read this
what if you need other input parameters for you business logic deviating from (req, res, next)? For example, if you want to hand over some configuration values to feed your logic? To achieve this, you can use a simple but efficient pattern: wrap your actual middleware function with a second one that receives the desired parameters, like so.
see codes
const paramMiddleware = (myParam) => {
return (req, res, next) => {
// implement your business logic using 'myParam'
// ...
next();
}
}
topic : understanding how to add custom parameters in Express middleware
read this
see codes
reference