Add express-to-koa definition (#23153)

* Add express-to-koa definition

* Fix types
This commit is contained in:
Xiaohan Zhang
2018-01-24 11:57:46 -05:00
committed by Andy
parent 6eb3057805
commit fef2c8c616
4 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
import * as Koa from 'koa';
import * as connect from 'connect';
import expressToKoa = require('express-to-koa');
const app = new Koa();
const middleware: connect.NextHandleFunction = (req, res, next) => {
// 'express middleware'
next();
};
app.use(expressToKoa(middleware));
app.listen(3000);

18
types/express-to-koa/index.d.ts vendored Normal file
View File

@@ -0,0 +1,18 @@
// Type definitions for express-to-koa 1.0
// Project: https://github.com/kaelzhang/express-to-koa
// Definitions by: Xiaohan Zhang <https://github.com/xiaohanzhang>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as Koa from "koa";
import { IncomingMessage, ServerResponse } from "http";
export = expressToKoa;
declare function expressToKoa(
middleware: (
req: IncomingMessage,
res: ServerResponse,
next: (err?: any) => void,
) => void
): Koa.Middleware;

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-to-koa-tests.ts"
]
}

View File

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