Add types for express-version-route (#30421)

This commit is contained in:
Weffe 2018-11-18 18:03:28 -08:00 committed by Pranav Senthilnathan
parent f884416c05
commit ab9aa12d1b
4 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,19 @@
import * as express from 'express';
import * as versionRouter from 'express-version-route';
const app = express();
const routesMap = new Map<string, express.Handler>([
["1.0", respondV1],
["2.0", respondV2]
]);
app.get('/test', versionRouter.route(routesMap));
function respondV1(req: express.Request, res: express.Response, next: express.NextFunction) {
res.status(200).send('ok v1');
}
function respondV2(req: express.Request, res: express.Response, next: express.NextFunction) {
res.status(200).send('ok v2');
}

View File

@ -0,0 +1,9 @@
// Type definitions for express-version-route 1.0
// Project: https://github.com/lirantal/express-version-route
// Definitions by: Rogelio Negrete <https://github.com/weffe>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import { Handler } from 'express';
export function route(versionsMap: Map<string, Handler>): Handler;

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"express-version-route-tests.ts"
]
}

View File

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