A function that will generate a middleware.
const myMiddleware = middlewareCreator((options = {}) => (app) => {
const message = options.message || 'Hello Charo!';
const responsesBuilder = app.get<ResponsesBuilder>('responsesBuilder');
return (_, res) => {
responsesBuilder.json({ res, data: { message } });
};
});
// ...
container.use(myMiddleware);
container.use(myMiddleware({ message: 'Hello Pili!' }));
Generated using TypeDoc
Generates a configurable middleware for the application to use. It's configurable because the
creator
, instead of just being sent to the container to mount, it can also be called as a function with custom parameters the middleware can receive.