import { type CompiledRoutePattern } from "./pattern.js"; /** HTTP methods the router accepts. */ export declare const METHODS: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]; export type Method = (typeof METHODS)[number]; export declare const EMPTY_PARAMS: Record; /** * Result of {@link Router.find}. The `found: false` cases deliberately separate * a missing path (404) from a path that exists for other methods (405), so the * server layer can answer correctly and populate an `Allow` header. */ export type RouterMatch = { readonly found: true; readonly payload: T; readonly params: Record; } | { readonly found: false; readonly reason: "not-found"; } | { readonly found: false; readonly reason: "method-not-allowed"; readonly allowed: string[]; }; /** * Radix-style segment trie router. Matching precedence is static > param > * wildcard. Parameter/wildcard values are returned RAW (not percent-decoded); * the server boundary decodes and rejects malformed encodings with a 400, * keeping this layer pure and allocation-light. * * @typeParam T - the payload stored per (method, path); a route descriptor in * practice, but the router is agnostic to it. */ export declare class Router { private readonly root; /** * Fast path: fully-static paths (no `:param`/`*`) resolve in a single map * lookup keyed by the full path, skipping the trie walk entirely. Values are * the same `Terminal` objects held in the trie, so adding a method later * updates both views at once. */ private readonly staticRoutes; /** * Scratch storage for param/wildcard captures during a synchronous trie walk. `find()` copies the * values into the returned params object before clearing this array, so returned matches never share * mutable state. Kept per Router instance, not module-global, to avoid cross-app coupling. */ private readonly paramValuesScratch; constructor(); /** * Register a payload for `method` + `path`. Throws {@link RouteConfigError} * (boot-time, L2) on a duplicate route, a malformed pattern, or conflicting * parameter names for the same path shape. */ add(method: Method, pattern: string | CompiledRoutePattern, payload: T): void; /** * Resolve `method` + `path`. Tolerant of a missing leading slash and of * method casing. Never throws. */ find(method: string, path: string): RouterMatch; private findDynamic; private maybeCacheDynamicMatch; } //# sourceMappingURL=router.d.ts.map