add microrouter types (#18500)

* add microrouter types

* add params field to IncomingMessage

* fix lint

* use micro types for RequestHandler
This commit is contained in:
Mathieu Dutour
2017-08-01 10:26:32 -07:00
committed by Sheetal Nandi
parent 32c1c2e72b
commit 2a641a97bf
3 changed files with 51 additions and 0 deletions

29
types/microrouter/index.d.ts vendored Normal file
View 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;

View 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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }