Skip to content

SudoSOS Back-end API / internal / middleware

Internal: Middleware ​

This is the module page of the async-validator-middleware.

Classes ​

ClassDescription
AsyncValidatorMiddlewareMiddleware that runs async (potentially DB-hitting) validation specs against the request body before passing to the handler. Runs after RequestValidatorMiddleware (structural Swagger check) and returns the same { valid, errors[] } shape on failure, ensuring a consistent 400 response regardless of which layer caught the error.
AsyncValidatorRegistry-
PolicyMiddlewareThis class is responsible for: - enforcing a given policy implementation as middleware.
RequestValidatorMiddlewareThis class is responsible for: - validating request models as middleware.
RestrictionMiddleware-
TokenMiddlewareThis class is responsible for: - parsing JWT tokens in the request Authorization header. - validating parsed JWT tokens. - refreshing the JWT tokens in the request header allowing sliding expiration.

Interfaces ​

InterfaceDescription
MiddlewareOptionsThe configuration options for the token middleware.
RegistryEntry-
RequestWithTokenExtend the Express request interface with a token property, which will be filled by this middleware.
TokenRestrictions-

Type Aliases ​

Type AliasDescription
BuildTargetBuilds the validation target from the request. When provided, the middleware calls this instead of using raw req.body, allowing specs that need route params, token data, or other request context.
SpecificationFactoryA factory function that returns a fresh Specification per call. This prevents ValidationError.join() from mutating shared trace instances across requests.

Variables ​

VariableDescription
globalAsyncValidatorRegistryGlobal singleton registry instance shared across all controllers.