import { type SpecialNextParam } from '../middlewares/shared.js'; import { MiddlewareCompositeAsync } from '../middlewares/composite-async.js'; import { MiddlewareRouteAsync } from './route-async.js'; import type { RouterOptions, Routes } from './router.js'; import type { Routable, RouteBuilderArguments } from './route.js'; import type { MiddlewareAsync } from '../middlewares/shared.js'; import type { UriTemplate } from '../uri-template/index.js'; export type RouteBuilderAsync = (...args: RouteBuilderArguments) => MiddlewareRouteAsync; /** * Dynamically applies asynchronous routes to a middleware composite. * * This function recursively processes route definitions and attaches them to the parent middleware chain. * * @template T - The context type containing the routable request and parameters. * @template TSpecialNextParam - The type for special next parameters (defaults to {@link SpecialNextParam}) * @param {Routes, TSpecialNextParam>} routes - Route definitions mapping URI templates to handler functions or nested route objects * @param {MiddlewareCompositeAsync & { route: RouteBuilderAsync }} [parent] - Parent middleware container to attach routes to * @returns {MiddlewareCompositeAsync} Configured middleware composite with attached routes */ export declare function useRoutesAsync(routes: Routes, TSpecialNextParam>, parent?: MiddlewareCompositeAsync & { route: RouteBuilderAsync; }): MiddlewareCompositeAsync; /** * Base class for defining asynchronous routing middleware chains. * * Extends the middleware composite to provide route configuration capabilities for asynchronous handlers. * * @template T - The context type containing the routable request and parameters * @template TSpecialNextParam - The type for special next parameters (defaults to {@link SpecialNextParam}) * @extends {MiddlewareCompositeAsync} * @implements {MiddlewareAsync} */ export declare class RouterAsync; }, ...unknown[]], TSpecialNextParam extends SpecialNextParam = SpecialNextParam> extends MiddlewareCompositeAsync implements MiddlewareAsync { /** * Creates a new RouterAsync instance with optional configuration. * * @param {RouterOptions} [options] - Configuration options including middleware priority and name */ constructor(options?: RouterOptions); /** * Creates a new route configuration chain for defining route handlers. * * @function route * @param {...RouteBuilderArguments} args - Route configuration parameters (path template, HTTP method, etc.) * @returns {MiddlewareRouteAsync} Newly created route configuration instance */ route(...args: RouteBuilderArguments): MiddlewareRouteAsync; /** * Attaches a collection of route definitions to the router. * * @param {Routes, TSpecialNextParam>} routes - Route definitions to be applied * @returns {this} Current router instance for method chaining */ useRoutes(routes: Routes, TSpecialNextParam>): this; /** * Adds middleware to the router's chain either globally or for a specific route. * * @function useMiddleware * @param {string | UriTemplate | MiddlewareAsync} routeOrMiddleware - * Route definition (string/URI template) or middleware function * @param {...MiddlewareAsync} middlewares - Additional middleware functions * @returns {this} Current router instance for method chaining */ useMiddleware(...middlewares: MiddlewareAsync[]): this; useMiddleware(routeOrMiddleware: string | UriTemplate | MiddlewareAsync, ...middlewares: MiddlewareAsync[]): this; /** * Registers route handlers or middleware functions. * * @function use * @param {(string | UriTemplate | ((...args: T) => Promise))} routeOrHandler - * Route definition (string/URI template) or handler function * @param {...((...args: T) => Promise)} handlers - Additional handler functions * @returns {this} Current router instance for method chaining */ use(routeOrHandler: string | UriTemplate, ...handlers: ((...args: T) => Promise)[]): this; use(...handlers: ((...args: T) => Promise)[]): this; }