-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
36 lines (29 loc) · 866 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
/**
* Simple HTTPS Server
* Created by Alexey S. Kiselev on June 2017.
*/
// Modules
var https = require('https'),
http = require('http'),
fs = require('fs'),
path = require('path');
// HTTPS Server options
var serverOptions = {
key: fs.readFileSync(path.join(__dirname,'certificates','privatekey.pem')),
cert: fs.readFileSync(path.join(__dirname,'certificates','certificate.pem'))
};
// Create Server
var server = https.createServer(serverOptions);
// Create App
var app = require('./app');
// Listening on port 443
server.on('request',app);
server.listen(443, function () {
console.log('Starting server on https://localhost:443');
});
// Insecure
var insecureServer = http.createServer();
insecureServer.on('request',app);
insecureServer.listen(3000, function () {
console.log('Starting server on http://localhost:3000');
});