Requst Data
Request Data Keys
Implementing your own Request Data
Setting the Request Data
import { OperationMiddlewareFunction } from "@simply-openapi/controllers";
import { Unauthorized } from "http-errors";
const requestUserAdapterMiddleware: OperationMiddlewareFunction = (
ctx,
next,
) => {
const user = ctx.req.user;
if (!user) {
// Note: Any validation you want to perform against the data should be done
// by your middleware as well.
throw new Unauthorized();
}
ctx.setRequestData("x-user", user);
// It is important that next() is called and its value is returned, otherwise
// the request may be orphaned.
return next();
};Retrieving the Request Data in a method
Combining the middleware and request data parameters
Last updated