import type { Route } from "../types/index.js"; export interface RouteMatch { route: Route; params: Record; } /** * Result of a single-pass route resolution. * * Combines route matching, HEAD→GET fallback, and allowed-method * collection into one scan of the route table. */ export interface RouteResolution { /** The matched route and extracted params, or null if no match */ match: RouteMatch | null; /** Methods that match this path (populated when match is null and path exists for other methods) */ allowedMethods: string[]; } /** * Resolve a route in a single pass through the route table. * * For HEAD requests this also checks for a GET fallback. * When no exact match is found it collects all methods whose path * pattern matches (with constraints), enabling 405 responses and * OPTIONS Allow headers without a second scan. * * **Complexity**: O(n) — one pass regardless of outcome. */ export declare function resolveRoute(routes: Route[], method: string, path: string): RouteResolution; /** * Find a matching route for the given method and path. * * **Complexity**: O(n) where n is the number of registered routes. * Routes are tested sequentially until a match is found. * * This linear search is suitable for most applications (up to ~100 routes). * For applications with hundreds of routes, consider: * - Grouping routes by common prefixes (reduces regex tests per request) * - Using method-based route maps (the 405 "Method Not Allowed" check already * iterates separately, so grouping by method could help) * - Implementing a radix/prefix tree for static path segments * * The current design prioritizes simplicity and correctness. Route order matters: * the first matching route wins, allowing intentional route shadowing. */ export declare function findRoute(routes: Route[], method: string, path: string): RouteMatch | null; /** * Check if any route matches the path (regardless of method). */ export declare function hasMatchingPath(routes: Route[], path: string): boolean; /** * Find the first route whose path matches, regardless of HTTP method. * * Used by the OPTIONS/CORS preflight handler to locate group middleware * attached to a route at this path. */ export declare function findRouteByPath(routes: Route[], path: string): RouteMatch | null; /** * Get all allowed HTTP methods for a given path. * Respects route constraints when determining matches. * * @param routes - All registered routes * @param path - Path to check * @returns Array of allowed HTTP methods */ export declare function getAllowedMethods(routes: Route[], path: string): string[]; //# sourceMappingURL=find.d.ts.map