From 6deeda1da191b5519fc5ff8dda54674917bcee59 Mon Sep 17 00:00:00 2001 From: westlakem Date: Mon, 25 Jun 2018 11:02:47 -0400 Subject: [PATCH 1/3] Added http_proxy support --- src/Invoker.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Invoker.ts b/src/Invoker.ts index 304c30b..61211b1 100644 --- a/src/Invoker.ts +++ b/src/Invoker.ts @@ -3,8 +3,10 @@ import * as https from "https"; import * as path from "path"; import * as URL from "url"; +var ProxyAgent = require('proxy-agent'); // no typescript definitions + export class Invoker { - public static async invokeExpressFile(fileName: string, port: number, jsonRequest: any, restOfPath?:string): Promise { + public static async invokeExpressFile(fileName: string, port: number, jsonRequest: any, restOfPath?: string): Promise { const fullPath = path.join(process.cwd(), fileName); // Ensure the cache is removed always to be able to start the server on command @@ -84,6 +86,10 @@ export class Invoker { port: url.port ? parseInt(url.port, 10) : undefined, }; + if(process.env.http_proxy){ + (requestOptions as any).agent = new ProxyAgent(process.env.http_proxy) + } + return new Promise((resolve, reject) => { const req = httpModule.request(requestOptions, (response: any) => { if (response.statusCode !== 200) { @@ -116,4 +122,4 @@ export class Invoker { req.end(); }); } -} \ No newline at end of file +} From a8a76ad86f49599703c4d1bd466c3630706c97af Mon Sep 17 00:00:00 2001 From: westlakem Date: Mon, 25 Jun 2018 11:05:05 -0400 Subject: [PATCH 2/3] documentation for proxy --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 506ba3c..b0d2c5e 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,10 @@ const assistant = vga.VirtualGoogleAssistant.Builder() .create(); ``` +### Proxy settings + +If you need to use a custom proxy, just set your `HTTP_PROXY` environment variable. + # Against a Google Cloud Function file. Set the path to the Action on Google code. From 71229bbe518ce7484af014762da2b3b2b8bf15c9 Mon Sep 17 00:00:00 2001 From: westlakem Date: Mon, 25 Jun 2018 11:06:25 -0400 Subject: [PATCH 3/3] added proxy-agent to package --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 03eb8ca..36f6f5b 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "dependencies": { "@types/uuid": "^3.4.1", "lodash": "^4.17.4", + "proxy-agent": "^3.0.0", "uuid": "^3.1.0", "virtual-core": "0.0.11" },