route-trie
Version:
A minimal and powerful trie based url path router for Node.js.
53 lines (52 loc) • 1.22 kB
TypeScript
export interface TrieOptions {
ignoreCase?: boolean;
fixedPathRedirect?: boolean;
trailingSlashRedirect?: boolean;
}
export interface Params {
[index: string]: string;
}
export declare class Matched {
node: Node | null;
params: Params;
fpr: string;
tsr: string;
constructor();
}
interface Children {
[index: string]: Node;
}
export declare class Node {
name: string;
allow: string;
pattern: string;
suffix: string;
regex: RegExp | null;
endpoint: boolean;
wildcard: boolean;
varyChildren: Node[];
children: Children;
parent: Node | null;
private handlers;
private segment;
constructor(parent: Node | null);
handle(method: string, handler: any): void;
getHandler(method: string): any;
getAllow(): string;
getPattern(): string;
getSegments(): string;
}
export declare class Trie {
static NAME: string;
static VERSION: string;
static Node: typeof Node;
static Matched: typeof Matched;
root: Node;
private ignoreCase;
private fpr;
private tsr;
constructor(options?: TrieOptions);
define(pattern: string): Node;
match(path: string): Matched;
}
export default Trie;