ContextProvider: (request: RequestData<T>) => C | Promise<C>

Middleware can read request data and add information to the context that will be passed to the Action. If middleware throws an error, that error will fail the request and the Action will not be invoked. Expected cases should return a UserFacingError, which allows the request handler to know what data is safe to return to end users.

Middleware can provide validation in addition to parsing. For example, an auth middleware can have policies for validating auth in addition to passing auth context to the Action.

Type Parameters

Type declaration