alepha
Version:
Alepha is a convention-driven TypeScript framework for building robust, end-to-end type-safe applications, from serverless APIs to full-stack React apps.
45 lines • 1.2 kB
TypeScript
//#region src/providers/RouterProvider.d.ts
declare abstract class RouterProvider<T extends Route = Route> {
protected routePathRegex: RegExp;
protected tree: Tree<T>;
match(path: string): RouteMatch<T>;
protected test(path: string): void;
protected push(route: T): void;
protected createRouteMatch(path: string): RouteMatch<T>;
protected mapParams(match: RouteMatch<T>): RouteMatch<T>;
protected createParts(path: string): string[];
}
interface RouteMatch<T extends Route> {
route?: T;
params?: Record<string, string>;
}
interface Route {
path: string;
/**
* Rename a param in the route.
* This is automatically filled when you have scenarios like:
* `/customers/:id` and `/customers/:userId/payments`
*
* In this case, `:id` will be renamed to `:userId` in the second route.
*/
mapParams?: Record<string, string>;
}
interface Tree<T extends Route> {
route?: T;
children: {
[]: Tree<T>;
};
param?: {
route?: T;
name: string;
children: {
[]: Tree<T>;
};
};
wildcard?: {
route: T;
};
}
//#endregion
export { Route, RouteMatch, RouterProvider, Tree };
//# sourceMappingURL=index.d.ts.map