1
0

docs: Include website
All checks were successful
Remote Deploy / deploy (push) Successful in 6s

This commit is contained in:
2025-12-20 18:55:49 +01:00
parent e4eadc2b1a
commit 55a2eaaeb4
13 changed files with 465 additions and 10 deletions

View File

@@ -11,13 +11,20 @@ globalThis.File = class File {};
app.use(bodyParser.json());
app.get('/', async (_, res) => {
const dataStr = await fs.readFile(path.join(process.cwd(), "db", "current.json"), "utf8");
const data = JSON.parse(dataStr);
app.get('/', async (req, res) => {
const userAgent = req.headers['user-agent'] || '';
const isBrowser = /Mozilla|Chrome|Firefox|Safari|Edg/.test(userAgent);
data["status"]["currentUpdateSchedule"] = getCurrentInterval();
if (isBrowser) {
res.sendFile(path.join(process.cwd(), "web", "public", "index.html"));
} else {
const dataStr = await fs.readFile(path.join(process.cwd(), "db", "current.json"), "utf8");
const data = JSON.parse(dataStr);
res.json(data);
data["status"]["currentUpdateSchedule"] = getCurrentInterval();
res.json(data);
}
});
app.get('/versioned/v1', async (_, res) => {
@@ -49,13 +56,9 @@ app.post("/report", async (req, res) => {
return res.status(400).json({ error: "Invalid location value." });
}
const url = `https://n8n.local.jzitnik.dev/webhook/${process.env.WEBHOOK_UUID}`;
console.log(url)
let resp;
try {
resp = await fetch(url, {
method: "POST",
@@ -77,6 +80,11 @@ app.post("/report", async (req, res) => {
res.status(200).json({ message: "Report received successfully." });
});
app.use(express.static(path.join(process.cwd(), 'web/public'), {
index: 'index.html',
extensions: ['html'],
}));
app.listen(PORT, () => {
console.log(`Server is running at http://localhost:${PORT}`);
});