-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (28 loc) · 1.03 KB
/
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
35
36
37
38
'use strict';
import express from 'express';
import https from 'https';
import http from 'http';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import config from './lib/config.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const app = express();
const httpsPort = config.get('publicServerOptions').httpsPort;
const httpPort = config.get('publicServerOptions').httpPort;
console.log(config.get('privateServerOptions').sslKeyPath);
console.log(config.get('privateServerOptions').sslCertPath);
const options = {
key: fs.readFileSync(config.get('privateServerOptions').sslKeyPath),
cert: fs.readFileSync(config.get('privateServerOptions').sslCertPath)
}
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'));
});
https.createServer(options, app).listen(httpsPort, () => {
console.log(`https started on port ${httpsPort}`);
});
http.createServer(app).listen(httpPort, () => {
console.log(`http started on port ${httpPort}`);
});