-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
53 lines (50 loc) · 1.8 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Generated by LiveScript 1.2.0
/*
CC0 1.0 Universal
To the extent possible under law, 唐鳳 has waived all copyright and
related or neighboring rights to EtherCalc.
This work is published from Taiwan.
<http://creativecommons.org/publicdomain/zero/1.0>
*/
(function(){
var slurp, argv, json, port, host, basepath, keyfile, certfile, key, polling, cors, expire, transport, options, replace$ = ''.replace;
slurp = function(it){
return require('fs').readFileSync(it, 'utf8');
};
argv = (function(){
try {
return require('optimist').boolean(['vm', 'polling', 'cors']).argv;
} catch (e$) {}
}()) || {};
json = (function(){
try {
return JSON.parse(slurp('/home/dotcloud/environment.json'));
} catch (e$) {}
}());
port = Number(argv.port || (json != null ? json.PORT_NODEJS : void 8) || process.env.PORT || process.env.VCAP_APP_PORT || process.env.OPENSHIFT_INTERNAL_PORT) || 8000;
host = argv.host || process.env.VCAP_APP_HOST || process.env.OPENSHIFT_INTERNAL_IP || '0.0.0.0';
basepath = replace$.call(argv.basepath || "", /\/$/, '');
keyfile = argv.keyfile, certfile = argv.certfile, key = argv.key, polling = argv.polling, cors = argv.cors, expire = argv.expire;
transport = 'http';
if (keyfile != null && certfile != null) {
options = {
https: {
key: slurp(keyfile),
cert: slurp(certfile)
}
};
transport = 'https';
}
console.log("Please connect to: " + transport + "://" + (host === '0.0.0.0' ? require('os').hostname() : host) + ":" + port + "/");
require('zappajs')(port, host, options, function(){
this.KEY = key;
this.BASEPATH = basepath;
this.POLLING = polling;
this.CORS = cors;
this.EXPIRE = +expire;
if (isNaN(this.EXPIRE)) {
this.EXPIRE = 0;
}
return this.include('main');
});
}).call(this);