import { RouteParameter } from "./Contracts.mjs"; import { Middleware } from "./types/express.mjs"; import { Middleware as Middleware$1 } from "./types/h3.mjs"; import { ClearRequest } from "./ClearRequest.mjs"; import { HttpMethod, RequestData } from "./types/basic.mjs"; //#region src/Route.d.ts /** * Parse the placeholder parameters declared in a domain/host pattern such as * `{account}.example.com`. Mirrors the path parameter syntax (supporting the * optional `{name?}` form) so domain parameters feel consistent with path ones. * * @param pattern * @returns */ declare const parseDomainParameters: (pattern?: string) => RouteParameter[]; /** * Resolvers wired up by `CoreRouter` so the `Route` facade can expose the * currently dispatching route without depending on the router directly. */ interface CurrentRouteResolvers { current: () => Route | undefined; currentRouteName: () => string; currentRouteAction: () => string; } /** * @class clear-router Route * @description A route describes a single enpoint on clear-router * @author 3m1n3nc3 * @repository https://github.com/arkstack-hq/clear-router */ declare class Route { ctx: X; body: RequestData; query: RequestData; params: RequestData; clearRequest: ClearRequest; methods: HttpMethod[]; path: string; registrationPaths: string[]; parameters: RouteParameter[]; routeName?: string; handler: H; middlewares: M[]; controllerName?: string; actionName?: string; handlerType: 'function' | 'controller'; middlewareCount: number; domainPattern?: string; domainParameters: RouteParameter[]; constraints: Record; constructor(methods: HttpMethod[], path: string, handler: H, middlewares?: M[], options?: { registrationPaths?: string[]; parameters?: RouteParameter[]; domain?: string; onName?: (name: string, route: Route, previousName?: string) => void; normalizeMiddleware?: (middleware: M) => M; }); private onName?; private normalizeMiddleware?; private static currentResolvers?; /** * Wire the resolvers used by the static `current*` accessors. Called once by * `CoreRouter` so `Route.current()` reflects the active request. * * @internal * @param resolvers */ static bindCurrentResolvers(resolvers: CurrentRouteResolvers): void; /** * Get the route currently being dispatched, if any. * * @returns */ static current(): Route | undefined; /** * Get the name of the route currently being dispatched. * * @returns */ static currentRouteName(): string; /** * Get the action (controller@method or `Closure`) of the route currently * being dispatched. * * @returns */ static currentRouteAction(): string; /** * The route action expressed as `Controller@method` for controller routes or * `Closure` for callback routes. */ get action(): string; /** * Set the route name * * @param name * @returns */ name(name: string): this; /** * Constrain the route to a host pattern such as `{account}.example.com`. * Any `{placeholder}` segments are exposed as route parameters once matched. * * @param pattern * @returns */ domain(pattern: string): this; /** * Constrain one or more route parameters with a regular expression. Accepts * either `where(name, pattern)` or `where({ name: pattern, ... })`. * * @param name * @param pattern * @returns */ where(name: string | Record, pattern?: string | RegExp): this; /** * Constrain the given parameters to numeric values. * * @param names * @returns */ whereNumber(...names: string[]): this; /** * Constrain the given parameters to alphabetic values. * * @param names * @returns */ whereAlpha(...names: string[]): this; /** * Constrain the given parameters to alphanumeric values. * * @param names * @returns */ whereAlphaNumeric(...names: string[]): this; /** * Constrain the given parameters to UUID values. * * @param names * @returns */ whereUuid(...names: string[]): this; /** * Constrain the given parameters to ULID values. * * @param names * @returns */ whereUlid(...names: string[]): this; /** * Constrain a parameter to one of the given values. * * @param name * @param values * @returns */ whereIn(name: string, values: Array): this; private applyConstraint; /** * Register one or more middleware that will be executed before the route. * * @param middlewares * @returns */ middleware(middlewares: M[] | M): this; /** * Resolve the route's domain pattern into a concrete host using the given * parameters. * * @param params * @returns */ private resolveDomainHost; /** * Get the path generated and accessible by this route * * @param params * @returns */ toPath(params?: RequestData): string; } //#endregion export { Route, parseDomainParameters };