import type { Express, NextFunction, Request, Response } from 'express'; import type { Application } from './Application.js'; type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch'; export type RequestHandler = (req: Request, res: Response, next: NextFunction) => void | Promise; export type ControllerConstructor = new (...args: never[]) => TInstance; export type ControllerTuple & string> = [TController, TMethodName]; /** * - A normal Express handler. * - **`[Controller, "method"]`** — class + method name; the application resolves the controller per request. */ export type RouteAction = RequestHandler | ControllerTuple; /** * Optional metadata when registering a route. */ export interface RouteOptions { /** Named route key for reverse lookup (e.g. `users.index`). */ name?: string; /** Registered middleware names applied after any group middleware. */ middleware?: string[]; } interface NamedRouteEntry { method: HttpMethod; path: string; } /** * Fluent routing API with groups, named routes, and middleware aliases. */ export declare class Route { private static readonly routes; private static readonly namedMiddleware; private static readonly namedRoutes; private static readonly groupPrefixStack; private static readonly groupMiddlewareStack; private static application; /** * Register a named middleware alias (two-argument form). * * @param name - Alias used in {@link RouteOptions.middleware} and middleware groups. * @param handler - Express middleware. */ static middleware(name: string, handler: RequestHandler): void; /** * Apply middleware aliases to routes registered inside `group` (single-argument form). * * @param names - One or more registered middleware names. * @returns Object with `group` callback. */ static middleware(names: string | readonly string[]): { group: (callback: () => void) => void; }; /** * Create a route group with a shared path prefix. * * @param prefix - URL prefix (leading `/` optional). * @param callback - Nested route registrations. */ static group(prefix: string, callback: () => void): void; /** * Register a GET route. * * @param path - URL path. * @param handler - Closure or `[Controller, 'method']` tuple. * @param options - Optional name and per-route middleware. */ static get(path: string, handler: RouteAction, options?: RouteOptions): void; /** * Register a POST route. * * @param path - URL path. * @param handler - Closure or controller tuple. * @param options - Optional name and middleware. */ static post(path: string, handler: RouteAction, options?: RouteOptions): void; /** * Register a PUT route. * * @param path - URL path. * @param handler - Closure or controller tuple. * @param options - Optional name and middleware. */ static put(path: string, handler: RouteAction, options?: RouteOptions): void; /** * Register a PATCH route. * * @param path - URL path. * @param handler - Closure or controller tuple. * @param options - Optional name and middleware. */ static patch(path: string, handler: RouteAction, options?: RouteOptions): void; /** * Register a DELETE route. * * @param path - URL path. * @param handler - Closure or controller tuple. * @param options - Optional name and middleware. */ static delete(path: string, handler: RouteAction, options?: RouteOptions): void; /** * Look up a named route (path as registered, including group prefixes). * * @param name - Name from {@link RouteOptions.name}. * @returns Method + path, or `undefined` if unknown. */ static getNamedRoute(name: string): NamedRouteEntry | undefined; /** * Clear all registrations (intended for tests). */ static resetForTests(): void; /** * Attach registered routes to an Express application. * * @param expressApp - Target Express instance. * @param application - Owning application (used to resolve class controllers). */ static bind(expressApp: Express, application: Application): void; private static flattenGroupMiddleware; private static add; private static applyGroupPrefix; private static toExpressHandler; } export {}; //# sourceMappingURL=Router.d.ts.map