add superagent-proxy types (#41691)

This commit is contained in:
dwieeb 2020-01-17 11:29:06 -08:00 committed by Eli Barzilay
parent 6d5145eb99
commit d62fccf391
4 changed files with 55 additions and 0 deletions

17
types/superagent-proxy/index.d.ts vendored Normal file
View File

@ -0,0 +1,17 @@
// Type definitions for superagent-proxy 2.0
// Project: https://github.com/TooTallNate/superagent-proxy#readme
// Definitions by: Daniel Imhoff <https://github.com/dwieeb>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import * as superagent from 'superagent';
declare module 'superagent' {
interface Request {
proxy(url: string): this;
}
}
declare function superagentProxy(s: typeof superagent): void;
export = superagentProxy;

View File

@ -0,0 +1,14 @@
import request = require('superagent');
import proxy = require('superagent-proxy');
// Patch superagent with `.proxy()` method
proxy(request);
const callback = (err: any, res: request.Response) => {};
const proxyUrl = 'http://localhost:8888';
// using proxy
request
.get('/search')
.proxy(proxyUrl)
.end(callback);

View File

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

View File

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