Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To use and env variable makes it difficult to use this library as part of other solutions, for example we plan on adding it to bst tools so that you can use similar commands to alexa.
It should be added as part of the VirtualGoogleAssistantBuilder


# Against a Google Cloud Function file.

Set the path to the Action on Google code.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
10 changes: 8 additions & 2 deletions src/Invoker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> {
public static async invokeExpressFile(fileName: string, port: number, jsonRequest: any, restOfPath?: string): Promise<any> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should include an extra parameter for the proxy.

const fullPath = path.join(process.cwd(), fileName);

// Ensure the cache is removed always to be able to start the server on command
Expand Down Expand Up @@ -84,6 +86,10 @@ export class Invoker {
port: url.port ? parseInt(url.port, 10) : undefined,
};

if(process.env.http_proxy){

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should come from the constructor instead of env

(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) {
Expand Down Expand Up @@ -116,4 +122,4 @@ export class Invoker {
req.end();
});
}
}
}