From 09a4aa40f4544ccb3ecb0a0438c95bb67383f149 Mon Sep 17 00:00:00 2001 From: kenneth Date: Sat, 25 Oct 2025 01:16:12 +0000 Subject: [PATCH] feat(backend): add code to serve dashboard Co-authored-by: Ona --- apps/backend/src/index.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/backend/src/index.ts b/apps/backend/src/index.ts index bd0a8a7..1ade2bc 100644 --- a/apps/backend/src/index.ts +++ b/apps/backend/src/index.ts @@ -1,6 +1,7 @@ import { Hono } from "hono" import { cors } from "hono/cors" import { logger } from "hono/logger" +import { serveStatic } from "hono/bun" import weather from "./weather" import tfl from "./tfl" import beszel from "./beszel" @@ -10,10 +11,6 @@ const app = new Hono() app.use("*", logger()) app.use("*", cors()) -app.get("/", (c) => { - return c.json({ message: "Hello from Bun + Hono!" }) -}) - app.get("/api/health", (c) => { return c.json({ status: "ok", timestamp: new Date().toISOString() }) }) @@ -27,6 +24,12 @@ app.route("/api/tfl", tfl) // Mount Beszel routes app.route("/api/beszel", beszel) +// Serve static files from dashboard build +app.use("/*", serveStatic({ root: "../dashboard/dist" })) + +// Fallback to index.html for client-side routing +app.get("*", serveStatic({ path: "../dashboard/dist/index.html" })) + export default { port: 8000, fetch: app.fetch,