feat: dashboard, visual query builder, expanded query language, cert expiry support

This commit is contained in:
M1
2026-03-16 12:26:17 +04:00
parent 97c08b1951
commit 500132ba05
14 changed files with 1578 additions and 34 deletions
+6 -1
View File
@@ -8,6 +8,10 @@ export const checks = new Elysia()
const token = headers["x-monitor-token"];
if (token !== process.env.MONITOR_TOKEN) return error(401, { error: "Unauthorized" });
// Merge cert_expiry_days into meta if present
const meta = body.meta ? { ...body.meta } : {};
if (body.cert_expiry_days != null) meta.cert_expiry_days = body.cert_expiry_days;
await sql`
INSERT INTO check_results (monitor_id, status_code, latency_ms, up, error, meta)
VALUES (
@@ -16,7 +20,7 @@ export const checks = new Elysia()
${body.latency_ms ?? null},
${body.up},
${body.error ?? null},
${body.meta ? sql.json(body.meta) : null}
${Object.keys(meta).length > 0 ? sql.json(meta) : null}
)
`;
return { ok: true };
@@ -27,6 +31,7 @@ export const checks = new Elysia()
latency_ms: t.Optional(t.Number()),
up: t.Boolean(),
error: t.Optional(t.Nullable(t.String())),
cert_expiry_days: t.Optional(t.Nullable(t.Number())),
meta: t.Optional(t.Any()),
}),
detail: { summary: "Ingest result (monitor runner)", tags: ["internal"] },
+15
View File
@@ -0,0 +1,15 @@
import { Elysia } from "elysia";
import { resolve } from "path";
const dir = resolve(import.meta.dir, "../dashboard");
export const dashboard = new Elysia()
// Static assets
.get("/dashboard/app.js", () => Bun.file(`${dir}/app.js`))
.get("/dashboard/query-builder.js", () => Bun.file(`${dir}/query-builder.js`))
// Pages
.get("/dashboard", () => Bun.file(`${dir}/index.html`))
.get("/dashboard/home", () => Bun.file(`${dir}/home.html`))
.get("/dashboard/monitors/new", () => Bun.file(`${dir}/new.html`))
.get("/dashboard/monitors/:id", () => Bun.file(`${dir}/detail.html`));