mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* Revert "Express: improve type of `Request['params']` aka `req.params` (#37502)"
This reverts commit 9aa863ef23.
* Express: use generics for params, default to dictionary
* Lint
* Bump all dependants
* Spacing
* Bump dependants
* Bump dependants
* Bump dependants
* Bump dependants
* Bump dependants
* Bump dependants
* Bump dependants
* Bump dependants
* Bump dependants
* Bump dependants
* Bump dependants (via tests)
* Bump dependants
* Bump dependants (via tests)
* Bump dependants
* Simplify test
* Hoist imports
* Tidy test
* Add tests
* Add reasons
* Remove redundant params
* Add tests
* Format
* Remove redundant params
* Add tests
* Add JSDoc
* Improve comment
* Improve comment
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
// Type definitions for named-routes 2.0
|
|
// Project: https://github.com/alubbe/named-routes#readme
|
|
// Definitions by: Philipp Katz <https://github.com/qqilihq>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
// TypeScript Version: 2.3
|
|
|
|
import * as express from 'express';
|
|
|
|
declare module 'express-serve-static-core' {
|
|
interface Application {
|
|
namedRoutes: NamedRouter;
|
|
}
|
|
// tslint:disable-next-line interface-name
|
|
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;
|