url-route-handler
Version:
The library provides a flexible and efficient way to map URL patterns to their respective handler methods. By defining a set of URL patterns and the corresponding handler functions, this package allows seamless routing, ensuring that each url is processed
35 lines (31 loc) • 852 B
TypeScript
type UrlOptions = {
url: string;
host: string;
origin: string;
pathname: string;
protocol: string;
query: Record<string, string>;
params: Record<string, any>;
hash: string;
};
declare class RouteLayer {
handle: (...args: any) => any;
name: any;
params: any;
path: any;
regexp: RegExp;
keys: any;
constructor(path: string, options: Record<string, any>, callback: (obj: UrlOptions, ...args: any) => any);
match(path: string): boolean;
handleError(err: any): {
status: string;
message: any;
};
handleRequest(urlObj: UrlOptions, ...args: any): any;
}
declare class Router {
layers: RouteLayer[];
use(path: string, callback: (obj: UrlOptions, ...args: any) => any): void;
handle(url: string, ...args: any): any;
}
export { Router, type UrlOptions };