Extend parameters of already defined method
Solution 1:
You don't need to add an extra parameter. app.use wants a function as first parameter. So, you can create a function that returns the desired function to use in app.use.
const dbInjector = (mongoState) => {
return async (ctx, next) => {
ctx.state.mongoState = mongoState;
await next();
};
};
And now you can use this in app.use:
app.use(dbInjector(mongoState));