-
Notifications
You must be signed in to change notification settings - Fork 8
/
server.js
37 lines (29 loc) · 979 Bytes
/
server.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
'use strict';
var https = require('https');
var http = require('http');
var fs = require('fs');
var app = require('./app.js');
var config = require('./config/config.js');
var db = require('./app/models/db.js');
// Start the app by listening on <port>
var port = config.port;
// Load functions into postgres - wierd spot to put this, but it works
db.insertPgFunctions(function () {
if (process.env.NODE_ENV === 'dev') {
var options = { // Enables node ssl for dev., prod uses nginx ssl
key: fs.readFileSync('./dev_ssl/server.key'),
cert: fs.readFileSync('./dev_ssl/server.crt'),
};
https.createServer(options, app).listen(port);
}
else {
http.createServer(app).listen(port);
}
});
// var daemon = require('./app/models/block_io-daemon.js')(6, 20000);
// daemon.on('deposit', log);
// daemon.on('error', log);
// function log (stuff) {
// console.log('deposit daemon: ', stuff);
// }
console.log('Express app started on port ' + port);