SudoSOS Back-end API / internal / middleware
Internal: Middleware ​
This is the module page of the async-validator-middleware.
Classes ​
| Class | Description |
|---|---|
| AsyncValidatorMiddleware | Middleware 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 | - |
| PolicyMiddleware | This class is responsible for: - enforcing a given policy implementation as middleware. |
| RequestContextMiddleware | This class is responsible for binding a RequestContext to every request, so that log lines can be correlated per request. It should be registered before any router, as requests that are rejected by other middleware are the ones that benefit the most from being correlatable. |
| RequestValidatorMiddleware | This class is responsible for: - validating request models as middleware. |
| RestrictionMiddleware | - |
| TokenMiddleware | This class is responsible for: - parsing JWT tokens in the request Authorization header. - validating parsed JWT tokens. - rejecting tokens of deleted users. - refreshing the JWT tokens in the request header allowing sliding expiration. |
Interfaces ​
| Interface | Description |
|---|---|
| MiddlewareOptions | The configuration options for the token middleware. |
| RegistryEntry | - |
| RequestWithToken | Extend the Express request interface with a token property, which will be filled by this middleware. |
| TokenRestrictions | - |
Type Aliases ​
| Type Alias | Description |
|---|---|
| BuildTarget | Builds 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. |
| SpecificationFactory | A factory function that returns a fresh Specification per call. This prevents ValidationError.join() from mutating shared trace instances across requests. |
Variables ​
| Variable | Description |
|---|---|
| globalAsyncValidatorRegistry | Global singleton registry instance shared across all controllers. |