|
|
@@ -11,12 +11,13 @@ var morgan = require('morgan');
|
|
11
|
11
|
var fs = require('fs');
|
|
12
|
12
|
var logDirectory = 'log'
|
|
13
|
13
|
var production = process.argv[2];
|
|
|
14
|
+/* istanbul ignore if */
|
|
14
|
15
|
if (production === "-p") {
|
|
15
|
16
|
var log_passwd = fs.readFileSync('logpasswd', 'utf-8');
|
|
16
|
17
|
}
|
|
17
|
18
|
|
|
18
|
19
|
scheduler.register_existing_events();
|
|
19
|
|
-
|
|
|
20
|
+/* istanbul ignore next */
|
|
20
|
21
|
var auth = function (req, res, next) {
|
|
21
|
22
|
function unauthorized(res) {
|
|
22
|
23
|
res.set('WWW-Authenticate', 'Basic realm=Authorization Required');
|
|
|
@@ -61,6 +62,7 @@ app.use(bodyParser.json()); // for parsing application/json
|
|
61
|
62
|
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
|
|
62
|
63
|
app.use('/', route_manager);
|
|
63
|
64
|
app.use('/source', require('magic-window')('/source', { ignore: ['config', 'redis', 'cert.pem', 'key.pem', 'dump.rdb', 'logpasswd'] }))
|
|
|
65
|
+/* istanbul ignore if */
|
|
64
|
66
|
if (production === "-p") {
|
|
65
|
67
|
app.use('/log', auth, express.static('log'));
|
|
66
|
68
|
app.use('/log', auth, serveIndex('log', {'icons': true}));
|
|
|
@@ -70,6 +72,7 @@ app.listen(3000, function () {
|
|
70
|
72
|
console.log('Now accepting connections on port 3000.');
|
|
71
|
73
|
});
|
|
72
|
74
|
|
|
|
75
|
+/* istanbul ignore if */
|
|
73
|
76
|
if (production === "-p") {
|
|
74
|
77
|
var prkey = fs.readFileSync('key.pem');
|
|
75
|
78
|
var certi = fs.readFileSync('cert.pem');
|