forked from monken/aws-sdk-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
23 lines (20 loc) · 750 Bytes
/
index.js
File metadata and controls
23 lines (20 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var AWS = require('aws-sdk');
var proxy = process.env['HTTPS_PROXY'] || process.env['https_proxy'] || process.env['http_proxy'];
var timeout = parseInt(process.env['AWS_HTTP_TIMEOUT']) || 240000;
var connectionTimeout = parseInt(process.env['AWS_HTTP_CONNECTION_TIMEOUT']) || 240000;
var isProduction = (typeof process.env['NODE_ENV'] !== 'undefined' && process.env['NODE_ENV'] === 'production');
if (isProduction && proxy) {
try {
AWS.config.update({
httpOptions: {
proxy: proxy,
timeout: timeout,
connectionTimeout: connectionTimeout
},
});
} catch (e) {
if (e.code === 'MODULE_NOT_FOUND') console.error('Install proxy-agent for proxy support.');
else throw e;
}
}
module.exports = AWS;