Merge pull request #22123 from wanganjun/master

add types for express-promise-router 2.0
This commit is contained in:
Mine Starks
2017-12-13 10:47:23 -08:00
committed by GitHub
4 changed files with 68 additions and 0 deletions
@@ -0,0 +1,12 @@
import Router = require("express-promise-router");
const router = Router();
router.get("/", (req, res) => {
// equivalent to calling next()
return Promise.resolve('next');
});
router.post("/", async (req, res) => {
// ...
});
+32
View File
@@ -0,0 +1,32 @@
// Type definitions for express-promise-router 2.0
// Project: https://github.com/express-promise-router/express-promise-router
// Definitions by: Anjun Wang <https://github.com/wanganjun>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/* =================== USAGE ===================
import Router = require('express-promise-router');
const router = Router();
router.get('/', (req, res) => {
// equivalent to calling next()
return Promise.resolve('next');
})
router.post('/', async (req, res) => {
// ...
})
export default router;
=============================================== */
import { Router } from "express";
/**
* A simple wrapper for Express 4's Router that allows middleware to return
* promises. If the promise is rejected, `express-promise-router` will call next
* with the reason
*/
declare const PromiseRouter: typeof Router;
export = PromiseRouter;
@@ -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-promise-router-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }