From fd4af848bc3125476eeb5c0416ec6c1bf8683774 Mon Sep 17 00:00:00 2001 From: M1 Date: Mon, 16 Mar 2026 13:33:44 +0400 Subject: [PATCH] fix: hide dashboard + internal routes from swagger docs --- apps/web/src/index.ts | 2 +- apps/web/src/routes/dashboard.ts | 17 ++++++++--------- apps/web/src/routes/internal.ts | 3 ++- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/web/src/index.ts b/apps/web/src/index.ts index 5118458..46c067b 100644 --- a/apps/web/src/index.ts +++ b/apps/web/src/index.ts @@ -13,7 +13,7 @@ await migrate(); const app = new Elysia() .use(cors()) .use(swagger({ path: "/docs", documentation: { info: { title: "PingQL API", version: "0.1.0" } } })) - .get("/", () => ({ name: "PingQL", version: "0.1.0", docs: "/docs", dashboard: "/dashboard" })) + .get("/", () => ({ name: "PingQL", version: "0.1.0", docs: "/docs", dashboard: "/dashboard" }), { detail: { hide: true } }) .use(dashboard) .use(auth) .use(account) diff --git a/apps/web/src/routes/dashboard.ts b/apps/web/src/routes/dashboard.ts index a33b23a..fbb534b 100644 --- a/apps/web/src/routes/dashboard.ts +++ b/apps/web/src/routes/dashboard.ts @@ -3,13 +3,12 @@ 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`)) +const hide = { detail: { hide: true } }; - // 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`)); +export const dashboard = new Elysia() + .get("/dashboard/app.js", () => Bun.file(`${dir}/app.js`), hide) + .get("/dashboard/query-builder.js", () => Bun.file(`${dir}/query-builder.js`), hide) + .get("/dashboard", () => Bun.file(`${dir}/index.html`), hide) + .get("/dashboard/home", () => Bun.file(`${dir}/home.html`), hide) + .get("/dashboard/monitors/new", () => Bun.file(`${dir}/new.html`), hide) + .get("/dashboard/monitors/:id", () => Bun.file(`${dir}/detail.html`), hide); diff --git a/apps/web/src/routes/internal.ts b/apps/web/src/routes/internal.ts index d46e468..23d73b2 100644 --- a/apps/web/src/routes/internal.ts +++ b/apps/web/src/routes/internal.ts @@ -4,7 +4,7 @@ import { Elysia } from "elysia"; import sql from "../db"; -export const internal = new Elysia({ prefix: "/internal" }) +export const internal = new Elysia({ prefix: "/internal", detail: { hide: true } }) .derive(({ headers, error }) => { if (headers["x-monitor-token"] !== process.env.MONITOR_TOKEN) return error(401, { error: "Unauthorized" }); @@ -13,6 +13,7 @@ export const internal = new Elysia({ prefix: "/internal" }) // Returns monitors that are due for a check .get("/due", async () => { + return sql` SELECT m.id, m.url, m.interval_s, m.query FROM monitors m