ran prettier lol
All checks were successful
CI / build (push) Successful in 10s

This commit is contained in:
Space-Banane
2026-02-22 15:31:37 +01:00
parent bc58cb7361
commit e1300a98b3
17 changed files with 473 additions and 408 deletions

View File

@@ -1,6 +1,6 @@
import express from 'express';
import fs from 'fs';
import path from 'path';
import express from "express";
import fs from "fs";
import path from "path";
export default async function webserver() {
const app = express();
@@ -8,13 +8,15 @@ export default async function webserver() {
app.use(express.json());
const webDir = path.join(__dirname, 'web');
const webDir = path.join(__dirname, "web");
if (fs.existsSync(webDir)) {
const files = fs.readdirSync(webDir).filter(f => f.endsWith('.ts') || f.endsWith('.js'));
const files = fs
.readdirSync(webDir)
.filter((f) => f.endsWith(".ts") || f.endsWith(".js"));
for (const file of files) {
const mod = await import(path.join(webDir, file));
const handler = mod.default ?? mod;
if (typeof handler === 'function') {
if (typeof handler === "function") {
await handler(app);
console.log(`[WEB] Loaded web route: ${file}`);
}
@@ -25,7 +27,7 @@ export default async function webserver() {
console.log(`[WEB] Web server is running on port ${PORT}`);
});
const IgnoredPaths = ['/favicon.ico', '/robots.txt', "/", "/hello"];
const IgnoredPaths = ["/favicon.ico", "/robots.txt", "/", "/hello"];
const KnownPaths = ["/git-commit", "/", "/health"];
// log all incoming requests
@@ -34,10 +36,14 @@ export default async function webserver() {
return next();
}
if (!KnownPaths.includes(req.url)) {
console.warn(`[WEB] Unknown Route request: ${req.method} ${req.url} {${req.ip}}`);
console.warn(
`[WEB] Unknown Route request: ${req.method} ${req.url} {${req.ip}}`,
);
} else {
console.log(`[WEB] Trusted Route request: ${req.method} ${req.url} {${req.ip}}`);
console.log(
`[WEB] Trusted Route request: ${req.method} ${req.url} {${req.ip}}`,
);
}
next();
});
}
}