-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
25 lines (20 loc) · 1.02 KB
/
server.js
File metadata and controls
25 lines (20 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var data = require('./data'); // Package for MongoDB connection with the Mongoose.
var app = require('./app.js')(data); // Send the MongoDB exchange package.
var https = require('https'); // Load HTTPS conection components.
var http = require('http'); // Load HTTP connection components.
var fs = require('fs'); // Read key & certificate.
// Set HTTPS options, key and certificate.
var options = {
key: fs.readFileSync('./ssl/local.key'),
cert: fs.readFileSync('./ssl/local.crt'),
requestCert: true,
rejectUnauthorized: false
};
app.set('port-ssl', process.env.PORT || 3443);
app.set('port', process.env.PORT || 3000);
var httpsServer = https.createServer(options, app).listen(app.get('port-ssl'), function(){
console.info('Express Secure Server: Listening on port ' + httpsServer.address().port);
});
var httpServer = http.createServer(app).listen(app.get('port'), function(){
console.info('Express Open Server: Listening on port ' + httpServer.address().port);
});