import { ClassMiddleware, MiddlewareHandle } from "../types/basic.mjs"; //#region src/decorators/middleware.d.ts /** * Any value accepted as a middleware by the router: a plain callback, a class * exposing a `handle` method, or an already-instantiated object exposing one. */ type MiddlewareInput = MiddlewareHandle | ClassMiddleware; /** * Decorator produced by {@link Middleware}. Works both as a class decorator (to * apply the middleware to every action of a controller) and as a method * decorator (to apply it to a single action). Supports the legacy * (`experimentalDecorators`) and TC39 standard decorator signatures. */ type MiddlewareDecorator = MethodDecorator & ClassDecorator & { any>(value: Value, context: ClassMethodDecoratorContext): void | Value; any>(value: Value, context: ClassDecoratorContext): void | Value; }; /** * Attach one or more middleware to a controller class or a controller method. * * @example * ```ts * @Middleware([auth]) * class AccountController {} * * class LoginController { * @Middleware(GuestMiddleware) * create () {} * } * ``` * * Accepts the middleware variadically or as arrays, and every supported * middleware shape: callbacks, middleware classes, or instances exposing a * `handle` method. * * @param middlewares * @returns */ declare function middleware(...middlewares: Array): MiddlewareDecorator; /** * Collect the decorator-declared middleware for a controller route handler, * ordered class-level first then method-level. Returns an empty array for * non-controller (callback) handlers or handlers without any decorators. * * @param handler * @returns */ declare function getControllerMiddlewares(handler: any): MiddlewareInput[]; //#endregion export { MiddlewareDecorator, MiddlewareInput, getControllerMiddlewares, middleware };