diff --git a/types/superagent-proxy/index.d.ts b/types/superagent-proxy/index.d.ts new file mode 100644 index 0000000000..6e9284748a --- /dev/null +++ b/types/superagent-proxy/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for superagent-proxy 2.0 +// Project: https://github.com/TooTallNate/superagent-proxy#readme +// Definitions by: Daniel Imhoff +// 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; diff --git a/types/superagent-proxy/superagent-proxy-tests.ts b/types/superagent-proxy/superagent-proxy-tests.ts new file mode 100644 index 0000000000..f5f98041fc --- /dev/null +++ b/types/superagent-proxy/superagent-proxy-tests.ts @@ -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); diff --git a/types/superagent-proxy/tsconfig.json b/types/superagent-proxy/tsconfig.json new file mode 100644 index 0000000000..88a6d6ab6b --- /dev/null +++ b/types/superagent-proxy/tsconfig.json @@ -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" + ] +} diff --git a/types/superagent-proxy/tslint.json b/types/superagent-proxy/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/superagent-proxy/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }