-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
34 lines (28 loc) · 903 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
#!/usr/bin/env node
var https = require('https'),
http = require('http'),
passport = require('passport'),
express = require('express');
var app = express();
var env = process.env.NODE_ENV || 'development';
var config = require('./config/config')[env];
// Load configuration
require('./config/mongoose')(config);
require('./config/passport')(passport);
require('./config/express')(app, passport);
var options = {
pfx: config.certificate,
passphrase: config.certificatePassphrase
};
if (env === "production") {
// Create an HTTPS service.
https.createServer(options, app).listen(config.port, function () {
console.log('HTTPS Server running on port ' + config.port + " " + env);
});
}
else {
// Create an HTTP service.
http.createServer(app).listen(3030, function () {
console.log('HTTP Server running on port: ' + 3030 + " " + env);
});
}