]> git.99rst.org Git - sgasser-llm-shield.git/commitdiff
Redirect root path to dashboard or health (#105)
authorStefan Gasser <redacted>
Tue, 23 Jun 2026 06:40:42 +0000 (08:40 +0200)
committerGitHub <redacted>
Tue, 23 Jun 2026 06:40:42 +0000 (08:40 +0200)
README.md
docs/installation.mdx
docs/quickstart.mdx
src/routes/health.test.ts
src/routes/health.ts

index 54ec8ba47bc4ce43d51ed96d05dd3e46b4edd2ab..c68b0cb521b16b2e080be896dfbafce0f7cab791 100644 (file)
--- 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
 
 <img src="assets/dashboard.png" width="100%" alt="PasteGuard Dashboard">
 
-[localhost:3000/dashboard](http://localhost:3000/dashboard)
+[localhost:3000](http://localhost:3000)
 
 ## What it catches
 
index 42487ecc67153df4f011cfb0110d96927a69c9ff..faa521112a2713c9bfe2e274d9ef24336144e11f 100644 (file)
@@ -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.
 
 <Note>
 The first start loads the detection model and can take a little longer; the
index 15653af60caa37c01df11d0fd655307296ed31c0..d8237ab9e1a965e75d071a85f2ae62624beab560 100644 (file)
@@ -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.
 
 <Note>
 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
index 97ebac1c130164e0d2768c855f49a353476ab5a3..3058a43fde18a3a9771321a2544060833c02615a 100644 (file)
@@ -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");
index a56ab795111818f95747c763c9c376954d188d06..b888e6e2f55d7b024c31d6e74451719601c70beb 100644 (file)
@@ -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;
git clone https://git.99rst.org/PROJECT