-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
42 lines (33 loc) · 1.02 KB
/
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
36
37
38
39
40
41
42
const express = require("express");
const https = require("https");
const compression = require("compression");
const fs = require("fs");
const env = require("./env.json");
const app = express();
app.use(compression());
app.use(express.static("static"));
app.use((req, res, next) => {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Content-Type", "*");
res.setHeader("Content-Range", "bytes");
next();
});
app.get("/", (req, res) => {
res.sendFile(__dirname + "/index.html");
});
app.get("/js", (req, res) => {
reqURL = req.url.replace("/js", "");
res.sendFile(__dirname + reqURL);
});
app.get("/index.html", (req, res) => {
res.sendFile(__dirname + "/index.html");
});
https.globalAgent.maxSockets = Infinity;
const options = {
key: fs.readFileSync("./certs/localhost.key"),
cert: fs.readFileSync("./certs/localhost.crt"),
};
https.createServer(options, app)
.listen(env.SERVER_PORT, () => {
console.log(`Server is listening on port ${env.SERVER_PORT}`);
});