feat: dashboard, visual query builder, expanded query language, cert expiry support
This commit is contained in:
@@ -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"] },
|
||||
|
||||
@@ -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`));
|
||||
Reference in New Issue
Block a user