mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-15 12:09:40 +08:00
add microrouter types (#18500)
* add microrouter types * add params field to IncomingMessage * fix lint * use micro types for RequestHandler
This commit is contained in:
committed by
Sheetal Nandi
parent
32c1c2e72b
commit
2a641a97bf
29
types/microrouter/index.d.ts
vendored
Normal file
29
types/microrouter/index.d.ts
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
// Type definitions for microrouter 2.2
|
||||
// Project: https://github.com/pedronauck/micro-router#readme
|
||||
// Definitions by: Mathieu Dutour <https://github.com/mathieudutour>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node"/>
|
||||
|
||||
import { IncomingMessage, ServerResponse, Server } from 'http';
|
||||
import { RequestHandler } from 'micro';
|
||||
|
||||
export type AugmentedRequestHandler = (
|
||||
req: IncomingMessage & {
|
||||
params: {[key: string]: string},
|
||||
query: {[key: string]: string}
|
||||
},
|
||||
res: ServerResponse
|
||||
) => any;
|
||||
|
||||
export type RouteHandler = (path: string, handler: AugmentedRequestHandler) => RequestHandler;
|
||||
|
||||
export function router(...routes: RequestHandler[]): RequestHandler;
|
||||
|
||||
export const get: RouteHandler;
|
||||
export const post: RouteHandler;
|
||||
export const put: RouteHandler;
|
||||
export const patch: RouteHandler;
|
||||
export const del: RouteHandler;
|
||||
export const head: RouteHandler;
|
||||
export const options: RouteHandler;
|
||||
21
types/microrouter/tsconfig.json
Normal file
21
types/microrouter/tsconfig.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts"
|
||||
]
|
||||
}
|
||||
1
types/microrouter/tslint.json
Normal file
1
types/microrouter/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user