This repository has been archived by the owner on Jun 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (43 loc) · 1.43 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
39
40
41
42
43
44
45
46
47
const express = require("express");
const helmet = require("helmet");
const path = require("path");
const expressStaticGzip = require("express-static-gzip");
const app = express();
// Apply basic express security
// We're skipping the CSP since the EVENT_STREAM could be from anywhere
app.use(helmet.dnsPrefetchControl());
app.use(helmet.expectCt());
app.use(helmet.frameguard());
app.use(helmet.hidePoweredBy());
app.use(helmet.hsts());
app.use(helmet.ieNoOpen());
app.use(helmet.noSniff());
app.use(helmet.permittedCrossDomainPolicies());
app.use(helmet.referrerPolicy());
app.use(helmet.xssFilter());
// Do this to serve our static assets and use the minified files
app.use(
expressStaticGzip(__dirname + "/dist", {
enableBrotli: true,
orderPreference: ["br", "gz"],
setHeaders: function (res, path) {
res.setHeader("Cache-Control", "public, max-age=31536000");
},
})
);
// Create 1 endpoint to get the Setting for the app from
// This is why we have this server at all
app.get("/settings", (req, res) => {
res.json({
EventStream:
process.env.EVENT_STREAM ||
// "https://api.sibr.dev/replay/v1/replay?from=2021-07-01T01:00:08.17Z",
"https://api.sibr.dev/corsmechanics/api.blaseball.com/events/streamData",
SiestaMessage: process.env.SIESTA_MESSAGE || null,
});
});
// Start web server
const port = process.env.PORT || 8080;
app.listen(port, () => {
console.log(`Server Started On Port ${port}`);
});