@jsonjoy.com/jit-router
Version:
High-performance HTTP router with JIT compilation.
38 lines • 1.39 kB
TypeScript
import type { Printable } from 'sonic-forest/lib/print/types';
import { type RouteMatcher } from './codegen';
import { RoutingTreeNode } from './tree';
import type { Step } from './types';
export interface RouterOptions {
defaultUntil?: string;
}
export declare class Router<Data = unknown> implements Printable {
readonly options: RouterOptions;
readonly destinations: Destination[];
constructor(options?: RouterOptions);
add(route: string | string[], data: Data): void;
addDestination(destination: Destination): void;
tree(): RoutingTreeNode;
compile(): RouteMatcher<Data>;
toString(tab?: string): string;
}
export declare class Destination implements Printable {
readonly routes: Route[];
readonly data: unknown;
static from(def: string | string[], data: unknown, defaultUntil?: string): Destination;
readonly match: Match;
constructor(routes: Route[], data: unknown);
toString(tab?: string): string;
}
export declare class Route implements Printable {
readonly steps: Step[];
static from(str: string, defaultUntil?: string): Route;
constructor(steps: Step[]);
toText(): string;
toString(tab?: string): string;
}
export declare class Match<Data = unknown> {
readonly data: Data;
params: string[] | null;
constructor(data: Data, params: string[] | null);
}
//# sourceMappingURL=router.d.ts.map