[koa-proxy] new type definitions (#37264)

This commit is contained in:
ishen7 2019-08-01 07:00:33 +08:00 committed by Jesse Trinity
parent 22dffbebe4
commit 97c54e5eea
4 changed files with 62 additions and 0 deletions

29
types/koa-proxy/index.d.ts vendored Normal file
View File

@ -0,0 +1,29 @@
// Type definitions for koa-proxy 1.0
// Project: https://github.com/edorivai/koa-proxy#readme
// Definitions by: ishen7 <https://github.com/ishen7>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as Koa from 'koa';
declare namespace proxy {
type RequestOptionFunc = (request: Koa.Request, opts: any) => any;
interface Options {
host?: string;
url?: string;
map?: { [key: string]: string };
match?: RegExp;
jar?: boolean;
suppressRequestHeaders?: string[]; // case-insensitive
suppressResponseHeaders?: string[]; // case-insensitive
overrideResponseHeaders?: any;
requestOptions?: RequestOptionFunc | { [key: string]: string };
followRedirect?: boolean;
yieldNext?: boolean;
}
}
declare function proxy(options?: proxy.Options): Koa.Middleware;
export = proxy;

View File

@ -0,0 +1,9 @@
import Koa = require('koa');
import proxy = require('koa-proxy');
const app = new Koa();
app.use(proxy({
host: 'https://api.github.com',
match: /^\/repos\//
}));
app.listen(3000);

View File

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

View File

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