feat(backend): add code to serve dashboard

Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
2025-10-25 01:16:12 +00:00
parent 220d25ccab
commit 09a4aa40f4

View File

@@ -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,