Installation
npm install --save @types/named-routes
Summary
This package contains type definitions for named-routes (https://github.com/alubbe/named-routes#readme).
Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/named-routes.
index.d.ts
import * as express from "express";
declare module "express-serve-static-core" {
interface Application {
namedRoutes: NamedRouter;
}
// eslint-disable-next-line @typescript-eslint/naming-convention
interface IRouterMatcher<T> {
(path: PathParams, name: string, ...handlers: RequestHandler[]): T;
(path: PathParams, name: string, ...handlers: RequestHandlerParams[]): T;
}
}
interface RouterOptions {
caseSensitive: boolean;
}
interface RouteOptions {
name: string;
recursiveWildcard: boolean;
caseSensitive: boolean;
wildcardInPairs: boolean;
}
interface RouteParams {
[key: string]: string | string[] | number | number[] | boolean | boolean[] | null;
}
declare class NamedRouter {
constructor(options?: Partial<RouterOptions>);
match(req: express.Request): boolean | object;
add(
method: string,
path: string,
callbacks: express.RequestHandler | express.RequestHandler[],
options?: Partial<RouteOptions>,
): void;
build(name: string, params?: RouteParams, method?: string): string;
registerAppHelpers(app: express.Express): NamedRouter;
param(name: string, callback: express.RequestHandler): NamedRouter;
param(callback: express.RequestHandler): NamedRouter;
dispatch(req: express.Request, res?: express.Response, next?: express.NextFunction): void;
extendExpress(app: express.Express | express.Router): NamedRouter;
}
export = NamedRouter;
Additional Details
- Last updated: Mon, 20 Nov 2023 23:36:24 GMT
- Dependencies: @types/express, @types/express-serve-static-core
Credits
These definitions were written by Philipp Katz.