-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
38 lines (31 loc) · 1005 Bytes
/
app.js
File metadata and controls
38 lines (31 loc) · 1005 Bytes
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
var express = require('express'),
http = require('http'),
https = require('https'),
fs = require('fs'),
path = require('path'),
settings = require('./settings')(),
proxy = require('./proxy'),
sslOptions
;
var mt3Js = require('./rewriters/response/html/injectors/external.js');
var app = express();
var port = process.env.PORT || settings.port;
app.use(express.favicon());
app.use(express.cookieParser(settings.cookieSecret));
app.use(express.logger('dev'));
app.use(mt3Js.middleware());
app.use(express.static(path.join(__dirname, '/public')));
app.use(proxy);
// start
http.createServer(app).listen(port, function(){
console.log('listening on port ' + port);
});
if (!settings.isProduction) {
sslOptions = {
key: fs.readFileSync('local_ssl/local.pem'),
cert: fs.readFileSync('local_ssl/local-cert.pem')
};
https.createServer(sslOptions, app).listen(settings.sslPort, function(){
console.log('listening on port ' + settings.sslPort);
});
}