1 | var exports = module.exports;
|
2 |
|
3 | exports.DEFAULT_GITANA_PROXY_SCHEME = "https";
|
4 | exports.DEFAULT_GITANA_PROXY_HOST = "api1.cloudcms.com";
|
5 | exports.DEFAULT_GITANA_PROXY_PORT = 443;
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | exports.autoUpgrade = function(hostOrUrl, verbose)
|
17 | {
|
18 |
|
19 | if (typeof(process.env.CLOUDCMS_API_PREFER_CDN) === "undefined") {
|
20 | process.env.CLOUDCMS_API_PREFER_CDN = "true";
|
21 | process.env.CLOUDCMS_API_PREFER_LB = "false";
|
22 | }
|
23 |
|
24 | if (hostOrUrl)
|
25 | {
|
26 | var handleReplaceHost = function(hostOrUrl, oldHost, newHost, verbose, loggerFn)
|
27 | {
|
28 | if (hostOrUrl.indexOf(oldHost) > -1)
|
29 | {
|
30 | if (verbose)
|
31 | {
|
32 | loggerFn(oldHost, newHost);
|
33 | }
|
34 |
|
35 | hostOrUrl = hostOrUrl.replace(oldHost, newHost);
|
36 | }
|
37 |
|
38 | return hostOrUrl;
|
39 | };
|
40 |
|
41 | if (process.env.CLOUDCMS_API_PREFER_CDN === true || process.env.CLOUDCMS_API_PREFER_CDN === "true")
|
42 | {
|
43 | hostOrUrl = handleReplaceHost(hostOrUrl, "api.cloudcms.com", "api1.cloudcms.com", verbose, function(oldHost, newHost) {
|
44 | console.log("Adjusting API connection to use CloudFront: " + oldHost + " to: " + newHost + " for improved edge performance");
|
45 | });
|
46 | }
|
47 | else if (process.env.CLOUDCMS_API_PREFER_LB === true || process.env.CLOUDCMS_API_PREFER_LB === "true")
|
48 | {
|
49 | hostOrUrl = handleReplaceHost(hostOrUrl, "api1.cloudcms.com", "api.cloudcms.com", verbose, function(oldHost, newHost) {
|
50 | console.log("Adjusting API connection to use Load Balancer: " + oldHost + " to: " + newHost);
|
51 | });
|
52 | }
|
53 | }
|
54 |
|
55 | return hostOrUrl;
|
56 | }; |
\ | No newline at end of file |