-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.js
40 lines (33 loc) · 857 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
35
36
37
38
39
40
import { ChemicalServer } from "chemicaljs";
import express from "express";
import httpProxy from "http-proxy";
import path from "node:path";
import compression from "compression";
const cdnProxy = httpProxy.createProxyServer();
const [app, listen] = new ChemicalServer();
const port = process.env.PORT || 8181;
app.disable("x-powered-by");
app.use(
express.static("dist", {
index: "index.html",
extensions: ["html"],
})
);
app.use(compression());
app.serveChemical();
app.use("/cdn", (req, res) => {
cdnProxy.web(req, res, {
target: "https://gms.parcoil.com/",
changeOrigin: true,
});
});
app.get("*", (_req, res) => {
res.sendFile(path.resolve("dist", "index.html"));
});
app.use((req, res) => {
res.status(404);
res.send("404 Error");
});
listen(port, () => {
console.log(`Starlight Running on port: ${port}`);
});