mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 20:39:17 +08:00
Add types for koa-requestid (#28676)
Simple interface for the koa-requestid Middleware. Please fill in this template. - [x ] Use a meaningful title for the pull request. Include the name of the package modified. - [x ] Test the change in your own code. (Compile and run.) - [x ] Add or edit tests to reflect the change. (Run with `npm test`.) - [x ] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request). - [ x] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes). - [x ] Run `npm run lint package-name` (or `tsc` if no `tslint.json` is present). Select one of these and delete the others: If adding a new definition: - [x ] The package does not already provide its own types, or cannot have its `.d.ts` files generated via `--declaration` - [x ] If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package. - [ x] Create it with `dts-gen --dt`, not by basing it on an existing project. - [x ] `tslint.json` should be present, and `tsconfig.json` should have `noImplicitAny`, `noImplicitThis`, `strictNullChecks`, and `strictFunctionTypes` set to `true`.
This commit is contained in:
committed by
Ryan Cavanaugh
parent
7a6975097c
commit
b443752450
15
types/koa-requestid/index.d.ts
vendored
Normal file
15
types/koa-requestid/index.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// Type definitions for koa-requestid 2.0
|
||||
// Project: https://github.com/seegno/koa-requestid/
|
||||
// Definitions by: Steven McDowall <https://github.com/sjmcdowall>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Middleware } from 'koa';
|
||||
|
||||
export = requestId;
|
||||
|
||||
declare function requestId(options?: {
|
||||
expose?: string;
|
||||
header?: string;
|
||||
query?: string;
|
||||
}): Middleware;
|
||||
10
types/koa-requestid/koa-requestid-tests.ts
Normal file
10
types/koa-requestid/koa-requestid-tests.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import Koa = require('koa');
|
||||
import requestId = require('koa-requestid');
|
||||
const app = new Koa();
|
||||
|
||||
app.use(requestId());
|
||||
app.use(async ctx => {
|
||||
ctx.body = ctx.state.id;
|
||||
});
|
||||
|
||||
app.listen(3000);
|
||||
23
types/koa-requestid/tsconfig.json
Normal file
23
types/koa-requestid/tsconfig.json
Normal 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",
|
||||
"koa-requestid-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/koa-requestid/tslint.json
Normal file
1
types/koa-requestid/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user