@types/express-serve-static-core
Advanced tools
Comparing version 4.17.19 to 4.17.20
@@ -99,2 +99,13 @@ // Type definitions for Express 4.17 | ||
export type RouteParameterNames<Route extends string> = | ||
string extends Route | ||
? string | ||
: Route extends `${string}:${infer Param}/${infer Rest}` | ||
? (Param | RouteParameterNames<Rest>) | ||
: (Route extends `${string}:${infer LastParam}` ? LastParam : never); | ||
export type RouteParameters<T extends string> = { | ||
[key in RouteParameterNames<T>]: string | ||
}; | ||
export interface IRouterMatcher< | ||
@@ -105,2 +116,28 @@ T, | ||
< | ||
Route extends string, | ||
P = RouteParameters<Route>, | ||
ResBody = any, | ||
ReqBody = any, | ||
ReqQuery = ParsedQs, | ||
Locals extends Record<string, any> = Record<string, any> | ||
>( | ||
// tslint:disable-next-line no-unnecessary-generics (it's used as the default type parameter for P) | ||
path: Route, | ||
// tslint:disable-next-line no-unnecessary-generics (This generic is meant to be passed explicitly.) | ||
...handlers: Array<RequestHandler<P, ResBody, ReqBody, ReqQuery, Locals>> | ||
): T; | ||
< | ||
Path extends string, | ||
P = RouteParameters<Path>, | ||
ResBody = any, | ||
ReqBody = any, | ||
ReqQuery = ParsedQs, | ||
Locals extends Record<string, any> = Record<string, any> | ||
>( | ||
// tslint:disable-next-line no-unnecessary-generics (it's used as the default type parameter for P) | ||
path: Path, | ||
// tslint:disable-next-line no-unnecessary-generics (This generic is meant to be passed explicitly.) | ||
...handlers: Array<RequestHandlerParams<P, ResBody, ReqBody, ReqQuery, Locals>> | ||
): T; | ||
< | ||
P = ParamsDictionary, | ||
@@ -130,6 +167,26 @@ ResBody = any, | ||
export interface IRouterHandler<T> { | ||
(...handlers: RequestHandler[]): T; | ||
(...handlers: RequestHandlerParams[]): T; | ||
export interface IRouterHandler<T, Route extends string = string> { | ||
(...handlers: Array<RequestHandler<RouteParameters<Route>>>): T; | ||
(...handlers: Array<RequestHandlerParams<RouteParameters<Route>>>): T; | ||
< | ||
P = RouteParameters<Route>, | ||
ResBody = any, | ||
ReqBody = any, | ||
ReqQuery = ParsedQs, | ||
Locals extends Record<string, any> = Record<string, any> | ||
>( | ||
// tslint:disable-next-line no-unnecessary-generics (This generic is meant to be passed explicitly.) | ||
...handlers: Array<RequestHandler<P, ResBody, ReqBody, ReqQuery, Locals>> | ||
): T; | ||
< | ||
P = RouteParameters<Route>, | ||
ResBody = any, | ||
ReqBody = any, | ||
ReqQuery = ParsedQs, | ||
Locals extends Record<string, any> = Record<string, any> | ||
>( | ||
// tslint:disable-next-line no-unnecessary-generics (This generic is meant to be passed explicitly.) | ||
...handlers: Array<RequestHandlerParams<P, ResBody, ReqBody, ReqQuery, Locals>> | ||
): T; | ||
< | ||
P = ParamsDictionary, | ||
@@ -227,2 +284,3 @@ ResBody = any, | ||
route<T extends string>(prefix: T): IRoute<T>; | ||
route(prefix: PathParams): IRoute; | ||
@@ -235,30 +293,30 @@ /** | ||
export interface IRoute { | ||
export interface IRoute<Route extends string = string> { | ||
path: string; | ||
stack: any; | ||
all: IRouterHandler<this>; | ||
get: IRouterHandler<this>; | ||
post: IRouterHandler<this>; | ||
put: IRouterHandler<this>; | ||
delete: IRouterHandler<this>; | ||
patch: IRouterHandler<this>; | ||
options: IRouterHandler<this>; | ||
head: IRouterHandler<this>; | ||
all: IRouterHandler<this, Route>; | ||
get: IRouterHandler<this, Route>; | ||
post: IRouterHandler<this, Route>; | ||
put: IRouterHandler<this, Route>; | ||
delete: IRouterHandler<this, Route>; | ||
patch: IRouterHandler<this, Route>; | ||
options: IRouterHandler<this, Route>; | ||
head: IRouterHandler<this, Route>; | ||
checkout: IRouterHandler<this>; | ||
copy: IRouterHandler<this>; | ||
lock: IRouterHandler<this>; | ||
merge: IRouterHandler<this>; | ||
mkactivity: IRouterHandler<this>; | ||
mkcol: IRouterHandler<this>; | ||
move: IRouterHandler<this>; | ||
'm-search': IRouterHandler<this>; | ||
notify: IRouterHandler<this>; | ||
purge: IRouterHandler<this>; | ||
report: IRouterHandler<this>; | ||
search: IRouterHandler<this>; | ||
subscribe: IRouterHandler<this>; | ||
trace: IRouterHandler<this>; | ||
unlock: IRouterHandler<this>; | ||
unsubscribe: IRouterHandler<this>; | ||
checkout: IRouterHandler<this, Route>; | ||
copy: IRouterHandler<this, Route>; | ||
lock: IRouterHandler<this, Route>; | ||
merge: IRouterHandler<this, Route>; | ||
mkactivity: IRouterHandler<this, Route>; | ||
mkcol: IRouterHandler<this, Route>; | ||
move: IRouterHandler<this, Route>; | ||
'm-search': IRouterHandler<this, Route>; | ||
notify: IRouterHandler<this, Route>; | ||
purge: IRouterHandler<this, Route>; | ||
report: IRouterHandler<this, Route>; | ||
search: IRouterHandler<this, Route>; | ||
subscribe: IRouterHandler<this, Route>; | ||
trace: IRouterHandler<this, Route>; | ||
unlock: IRouterHandler<this, Route>; | ||
unsubscribe: IRouterHandler<this, Route>; | ||
} | ||
@@ -265,0 +323,0 @@ |
{ | ||
"name": "@types/express-serve-static-core", | ||
"version": "4.17.19", | ||
"version": "4.17.20", | ||
"description": "TypeScript definitions for Express", | ||
@@ -50,2 +50,9 @@ "license": "MIT", | ||
"types": "index.d.ts", | ||
"typesVersions": { | ||
"<=4.0": { | ||
"*": [ | ||
"ts4.0/*" | ||
] | ||
} | ||
}, | ||
"repository": { | ||
@@ -62,4 +69,4 @@ "type": "git", | ||
}, | ||
"typesPublisherContentHash": "04a7fdec6461c3c59dd526fd0aa05b6e1cd8df4b4a0d0327c834087003ffbbbb", | ||
"typesPublisherContentHash": "19ec0e1ea3e2b0c3ec37b2a7294a7f0a0eaee0ffab6470a4781a08a6d796db2c", | ||
"typeScriptVersion": "3.5" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
### Additional Details | ||
* Last updated: Mon, 15 Mar 2021 17:47:32 GMT | ||
* Last updated: Tue, 25 May 2021 17:01:24 GMT | ||
* Dependencies: [@types/range-parser](https://npmjs.com/package/@types/range-parser), [@types/qs](https://npmjs.com/package/@types/qs), [@types/node](https://npmjs.com/package/@types/node) | ||
@@ -14,0 +14,0 @@ * Global values: none |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80822
5
2165