-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathserver.js
More file actions
27 lines (23 loc) · 826 Bytes
/
server.js
File metadata and controls
27 lines (23 loc) · 826 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
const https = require('https');
const http = require('http');
const app = require('./app');
const fs = require('fs');
const config = require('config');
const httpport = process.env.PORT || config.get('host').httpport ||3080,
httpsport = process.env.SECURE_PORT || config.get('host').httpsport ||3443;
var httpsOptions = {
key: fs.readFileSync('./app/cert/server.key')
, cert: fs.readFileSync('./app/cert/server.crt')
};
https.createServer(httpsOptions, app).listen(httpsport, function (err) {
if (err) {
throw err
}
console.log('Secure server is listening on '+httpsport+'...');
});
http.createServer(app).listen(httpport, function(err) {
if (err) {
throw err
}
console.log('Insecure server is listening on port ' + httpport + '...');
});