From: Stefan Gasser Date: Tue, 23 Jun 2026 06:40:42 +0000 (+0200) Subject: Redirect root path to dashboard or health (#105) X-Git-Tag: v0.7.0~12 X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=917b38e60e63254e3dc0690c661ee918352ce1a7;p=sgasser-llm-shield.git Redirect root path to dashboard or health (#105) --- diff --git a/README.md b/README.md index 54ec8ba..c68b0cb 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,8 @@ Run PasteGuard as a local proxy: docker run --rm -p 3000:3000 ghcr.io/sgasser/pasteguard:latest ``` +Open [localhost:3000](http://localhost:3000) for the dashboard. + Point your tools or app to PasteGuard instead of the provider: | Target | PasteGuard URL | Original URL | @@ -113,7 +115,7 @@ Every request is logged with masking details. See what was detected, what was ma PasteGuard Dashboard -[localhost:3000/dashboard](http://localhost:3000/dashboard) +[localhost:3000](http://localhost:3000) ## What it catches diff --git a/docs/installation.mdx b/docs/installation.mdx index 42487ec..faa5211 100644 --- a/docs/installation.mdx +++ b/docs/installation.mdx @@ -29,7 +29,7 @@ docker run --rm -p 3000:3000 ghcr.io/sgasser/pasteguard:latest ``` PasteGuard runs on `http://localhost:3000`. Open -[http://localhost:3000/dashboard](http://localhost:3000/dashboard) for the dashboard. +[http://localhost:3000](http://localhost:3000) for the dashboard. The first start loads the detection model and can take a little longer; the diff --git a/docs/quickstart.mdx b/docs/quickstart.mdx index 15653af..d8237ab 100644 --- a/docs/quickstart.mdx +++ b/docs/quickstart.mdx @@ -9,7 +9,7 @@ description: Run PasteGuard as a local proxy docker run --rm -p 3000:3000 ghcr.io/sgasser/pasteguard:latest ``` -PasteGuard runs on `http://localhost:3000`. Open `http://localhost:3000/dashboard` to see the dashboard. +PasteGuard runs on `http://localhost:3000`. Open `http://localhost:3000` to see the dashboard. For custom configuration or persistent logs, see [Installation](/installation). @@ -46,7 +46,7 @@ The name and email were masked before reaching OpenAI and restored in the respon ## 4. View Dashboard -Open `http://localhost:3000/dashboard` in your browser to see: +Open `http://localhost:3000` in your browser to see: - Request history - Detected PII entities diff --git a/src/routes/health.test.ts b/src/routes/health.test.ts index 97ebac1..3058a43 100644 --- a/src/routes/health.test.ts +++ b/src/routes/health.test.ts @@ -1,10 +1,38 @@ -import { describe, expect, test } from "bun:test"; +import { afterEach, describe, expect, test } from "bun:test"; import { Hono } from "hono"; +import { getConfig } from "../config"; import { healthRoutes } from "./health"; const app = new Hono(); app.route("/", healthRoutes); +const config = getConfig(); +const originalDashboardEnabled = config.dashboard.enabled; + +afterEach(() => { + config.dashboard.enabled = originalDashboardEnabled; +}); + +describe("GET /", () => { + test("redirects to dashboard when dashboard is enabled", async () => { + config.dashboard.enabled = true; + + const res = await app.request("/"); + + expect(res.status).toBe(302); + expect(res.headers.get("Location")).toBe("/dashboard"); + }); + + test("redirects to health when dashboard is disabled", async () => { + config.dashboard.enabled = false; + + const res = await app.request("/"); + + expect(res.status).toBe(302); + expect(res.headers.get("Location")).toBe("/health"); + }); +}); + describe("GET /health", () => { test("returns health status", async () => { const res = await app.request("/health"); diff --git a/src/routes/health.ts b/src/routes/health.ts index a56ab79..b888e6e 100644 --- a/src/routes/health.ts +++ b/src/routes/health.ts @@ -5,6 +5,11 @@ import { healthCheck as checkDetector } from "../services/pii"; export const healthRoutes = new Hono(); +healthRoutes.get("/", (c) => { + const config = getConfig(); + return c.redirect(config.dashboard.enabled ? "/dashboard" : "/health"); +}); + healthRoutes.get("/health", async (c) => { const config = getConfig(); const piiEnabled = config.pii_detection.enabled;