import { ClassType } from '@deepkit/core'; import { AppModule } from '@deepkit/app'; import { HttpRequest, HttpResponse } from './model.js'; import { InjectorModule } from '@deepkit/injector'; export type HttpMiddlewareFn = (req: HttpRequest, res: HttpResponse, next: (err?: any) => void) => void | Promise; export interface HttpMiddleware { execute: HttpMiddlewareFn; } export interface HttpMiddlewareRoute { path?: string; pathRegExp?: RegExp; httpMethod?: 'GET' | 'HEAD' | 'POST' | 'PATCH' | 'PUT' | 'DELETE' | 'OPTIONS' | 'TRACE'; category?: string; excludeCategory?: string; group?: string; excludeGroup?: string; } export declare class HttpMiddlewareConfig { name?: string; middlewares: (HttpMiddlewareFn | ClassType)[]; routes: HttpMiddlewareRoute[]; excludeRoutes: HttpMiddlewareRoute[]; order: number; controllers: ClassType[]; excludeControllers: ClassType[]; routeNames: string[]; excludeRouteNames: string[]; timeout?: number; modules: InjectorModule[]; selfModule: boolean; getClassTypes(): ClassType[]; } export declare class HttpMiddlewareApi { t: HttpMiddlewareConfig; name(name: string): void; for(...middlewares: (HttpMiddlewareFn | ClassType)[]): void; forRoutes(...routes: HttpMiddlewareRoute[]): void; excludeRoutes(...routes: HttpMiddlewareRoute[]): void; forRouteNames(...names: string[]): void; excludeRouteNames(...names: string[]): void; /** * When the middleware does not respond (either calling next() or sending headers) withing milliseconds, * automatically the next is executed and warning printed. */ timeout(timeout: number): void; forControllers(...controllers: ClassType[]): void; excludeControllers(...controllers: ClassType[]): void; /** * Per default middlewares are executed in the order they were registered. The default order is 0. A lower order means the middleware is executed earlier. */ order(order: number): void; forModules(...modules: AppModule[]): void; /** * Limit the middleware to the module where this middleware is defined. */ forSelfModules(): void; } export declare const httpMiddleware: import("@deepkit/type").FreeDecoratorResult; export declare type __ΩHttpMiddlewareFn = any[]; export declare type __ΩHttpMiddleware = any[]; export declare type __ΩHttpMiddlewareRoute = any[];