Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
],
"license": "MIT",
"repository": "pillarjs/router",
"types": "types/index.d.ts",
"dependencies": {
"array-flatten": "3.0.0",
"debug": "2.6.9",
Expand Down
38 changes: 38 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { IncomingMessage, ServerResponse } from "http";

type handler = (req:IncomingMessage, res:ServerResponse, next:Function) => void

interface Router {
(req:IncomingMessage, res:ServerResponse, next:Function):Router
get(path:string|handler[]|handler, handlers?:handler|handler[], handler?:handler):Router
post(path:string|handler[]|handler, handlers?:handler|handler[], handler?:handler):Router
put(path:string|handler[]|handler, handlers?:handler|handler[], handler?:handler):Router
patch(path:string|handler[]|handler, handlers?:handler|handler[], handler?:handler):Router
delete(path:string|handler[]|handler, handlers?:handler|handler[], handler?:handler):Router
route(path:string):Router
all(handler:|handler[]):Router
use(path:string|handler[]|handler, handler:handler|handler[]):Router

}
interface RouterOptions {
/**
* Enable case sensitivity.
*/
caseSensitive?: boolean | undefined;

/**
* Preserve the req.params values from the parent router.
* If the parent and the child have conflicting param names, the child’s value take precedence.
*
* @default false
* @since 4.5.0
*/
mergeParams?: boolean | undefined;

/**
* Enable strict routing.
*/
strict?: boolean | undefined;
}
declare function Router(options?:RouterOptions):Router
export = Router
23 changes: 23 additions & 0 deletions types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"moduleResolution": "node",
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": false,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": ["node"],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"./index.d.ts",
]
}