import type { NextFunction, Response } from 'express'; import Base from '../../../modules/Base.ts'; import type { IApp } from '../../../server.ts'; import type { StandardSchemaV1 } from '../../validate/types.ts'; import type { FrameworkRequest } from '../HttpServer.ts'; /** * One security scheme a middleware contributes to the OpenAPI document * (`components.securitySchemes`). Mirrors the OpenAPI Security Scheme Object: * `type: 'apiKey'` uses `name` + `in`; `type: 'http'` uses `scheme`. */ export interface AuthParameter { name: string; type: string; in?: string; scheme?: string; description: string; } declare class AbstractMiddleware extends Base { params?: Record; constructor(app: IApp, params?: Record); static get description(): string; /** * How requests send the credentials this middleware reads (a bearer token, * an API-key header, …), as OpenAPI security schemes. Declared * **statically** so the generator reads them off the class with zero * instantiation. Default `[]`. Reading alone documents auth as optional; * see {@link requiresAuth}. */ static get authSchemes(): AuthParameter[]; /** @deprecated Renamed to {@link authSchemes}; removed in v6. */ static get usedAuthParameters(): AuthParameter[]; /** * Whether this middleware rejects requests without an authenticated user * (`Auth`, `Role`). One such middleware anywhere in a route's chain makes * the route's OpenAPI security required; without one it is optional. */ static get requiresAuth(): boolean; /** * @deprecated Since 5.0.0 — declare auth schemes **statically** * (`static get authSchemes()`). The instance form will be removed in v6. */ get usedAuthParameters(): AuthParameter[]; /** * Schema describing query parameters this middleware consumes. Declared * **statically** so the framework (and codegen) can read it without * instantiating the middleware. Override with any Standard Schema-conformant * schema (Zod, Valibot, ArkType, yup ≥1.7, `defineSchema`). Default `null`. * * Example: * static get relatedQueryParameters() { * return z.object({ page: z.number(), limit: z.number() }); * } */ static get relatedQueryParameters(): StandardSchemaV1 | null; /** * Schema describing request-body parameters this middleware consumes. Static; * same rules as `relatedQueryParameters`. */ static get relatedRequestParameters(): StandardSchemaV1 | null; /** * @deprecated Since 5.0.0-beta.51 — declare the schema **statically** * (`static get relatedQueryParameters()`) instead. The instance form forces * the framework to instantiate the middleware just to read the schema (which * runs its constructor side effects); it will be removed in v6. */ get relatedQueryParameters(): StandardSchemaV1 | null; /** * @deprecated Since 5.0.0-beta.51 — use `static get relatedRequestParameters()`. * Removed in v6. */ get relatedRequestParameters(): StandardSchemaV1 | null; /** * @deprecated Since 5.0.0-beta.51 — read the static getters instead. * Removed in v6. */ get relatedReqParameters(): { request: StandardSchemaV1 | null; query: StandardSchemaV1 | null; }; /** * Translate a message with an in-code English default. The default is the * source of truth: it is returned when the request carries no i18n (direct * instantiation, i18n disabled), when the key is absent from the app's * locales, or when `t()` gives back something that is not a string * (malformed resource / `returnObjects`). A present key always wins. */ protected translate(req: FrameworkRequest, key: string, defaultValue: string): string; middleware(_req: FrameworkRequest, _res: Response, next: NextFunction): Promise; getMiddleware(): (_req: FrameworkRequest, _res: Response, next: NextFunction) => Promise; static get loggerGroup(): string; } export default AbstractMiddleware;