Some tyhigns.

This commit is contained in:
2026-03-11 00:27:19 -04:00
parent 3b1b4f63e2
commit cbd2270628
14 changed files with 571 additions and 163 deletions

View File

@@ -1,5 +1,6 @@
const express = require("express");
const path = require("path");
const fs = require("fs");
const isDev = process.env.NODE_ENV !== "production";
let livereload, connectLivereload;
if (isDev) {
@@ -8,6 +9,19 @@ if (isDev) {
}
const app = express();
const PORT = 3000;
const DOMAIN_FILE = path.join(__dirname, "domain.txt");
function readWsDomain() {
try {
const val = fs.readFileSync(DOMAIN_FILE, "utf8").trim();
if (val) return val;
} catch (err) {
if (err.code !== "ENOENT") {
console.warn("Failed to read domain.txt:", err.message);
}
}
return process.env.WS_DOMAIN || "localhost:8080";
}
if (isDev) {
const liveReloadServer = livereload.createServer();
@@ -17,6 +31,10 @@ if (isDev) {
app.use(express.static("public"));
app.get("/ws-domain", (_req, res) => {
res.json({ domain: readWsDomain() });
});
app.get("/", (req, res) => {
res.sendFile(path.join(__dirname, "public", "index.html"));
});