fix: hide dashboard + internal routes from swagger docs

This commit is contained in:
M1 2026-03-16 13:33:44 +04:00
parent fe7a0bf19b
commit fd4af848bc
3 changed files with 11 additions and 11 deletions

View File

@ -13,7 +13,7 @@ await migrate();
const app = new Elysia() const app = new Elysia()
.use(cors()) .use(cors())
.use(swagger({ path: "/docs", documentation: { info: { title: "PingQL API", version: "0.1.0" } } })) .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(dashboard)
.use(auth) .use(auth)
.use(account) .use(account)

View File

@ -3,13 +3,12 @@ import { resolve } from "path";
const dir = resolve(import.meta.dir, "../dashboard"); const dir = resolve(import.meta.dir, "../dashboard");
export const dashboard = new Elysia() const hide = { detail: { hide: true } };
// Static assets
.get("/dashboard/app.js", () => Bun.file(`${dir}/app.js`))
.get("/dashboard/query-builder.js", () => Bun.file(`${dir}/query-builder.js`))
// Pages export const dashboard = new Elysia()
.get("/dashboard", () => Bun.file(`${dir}/index.html`)) .get("/dashboard/app.js", () => Bun.file(`${dir}/app.js`), hide)
.get("/dashboard/home", () => Bun.file(`${dir}/home.html`)) .get("/dashboard/query-builder.js", () => Bun.file(`${dir}/query-builder.js`), hide)
.get("/dashboard/monitors/new", () => Bun.file(`${dir}/new.html`)) .get("/dashboard", () => Bun.file(`${dir}/index.html`), hide)
.get("/dashboard/monitors/:id", () => Bun.file(`${dir}/detail.html`)); .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);

View File

@ -4,7 +4,7 @@
import { Elysia } from "elysia"; import { Elysia } from "elysia";
import sql from "../db"; import sql from "../db";
export const internal = new Elysia({ prefix: "/internal" }) export const internal = new Elysia({ prefix: "/internal", detail: { hide: true } })
.derive(({ headers, error }) => { .derive(({ headers, error }) => {
if (headers["x-monitor-token"] !== process.env.MONITOR_TOKEN) if (headers["x-monitor-token"] !== process.env.MONITOR_TOKEN)
return error(401, { error: "Unauthorized" }); return error(401, { error: "Unauthorized" });
@ -13,6 +13,7 @@ export const internal = new Elysia({ prefix: "/internal" })
// Returns monitors that are due for a check // Returns monitors that are due for a check
.get("/due", async () => { .get("/due", async () => {
return sql` return sql`
SELECT m.id, m.url, m.interval_s, m.query SELECT m.id, m.url, m.interval_s, m.query
FROM monitors m FROM monitors m