-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (28 loc) · 925 Bytes
/
index.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
/*
*
* Node Js Api
*
*/
// Import Node libraries
const http = require('http');
const https = require('https');
const fs = require('fs');
const config = require('./lib/config');
const server = require('./lib/server');
// Create http server
httpServer = http.createServer((req, res) => server(req, res));
// listen to port 3000 on the http server
httpServer.listen(config.httpPort, () =>
console.log(`The http server is listening at ${config.httpPort} on ${config.envName}`)
);
//define https server options
httpsServerOptions = {
key: fs.readFileSync('./https/key.pem'),
cert: fs.readFileSync('./https/cert.pem')
};
// Create https server
httpsServer = https.createServer(httpsServerOptions, (req, res) => serverlib(req, res));
// listen to port 3001 on the https server
httpsServer.listen(config.httpsPort, () =>
console.log(`The https server is listening at ${config.httpsPort} on ${config.envName}`)
);