forked from titaniumnetwork-dev/nano
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (29 loc) · 770 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
import { ChemicalServer } from "chemicaljs";
import express from "express";
import { execSync } from "node:child_process";
import fs from "node:fs";
if (!fs.existsSync("dist")) {
console.log("No build folder found. Building...");
execSync("pnpm run build");
console.log("Built!");
}
const [app, listen] = new ChemicalServer({
scramjet: false,
rammerhead: false,
});
const port = process.env.PORT || 3000;
app.disable("x-powered-by");
app.use(
express.static("dist", {
index: "index.html",
extensions: ["html"],
}),
);
app.serveChemical();
app.use((req, res) => {
res.status(404);
res.sendFile("dist/index.html", { root: "." });
});
listen(port, () => {
console.log(`nano is listening on port ${port}`);
});