feat(backend): add code to serve dashboard
Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { Hono } from "hono"
|
import { Hono } from "hono"
|
||||||
import { cors } from "hono/cors"
|
import { cors } from "hono/cors"
|
||||||
import { logger } from "hono/logger"
|
import { logger } from "hono/logger"
|
||||||
|
import { serveStatic } from "hono/bun"
|
||||||
import weather from "./weather"
|
import weather from "./weather"
|
||||||
import tfl from "./tfl"
|
import tfl from "./tfl"
|
||||||
import beszel from "./beszel"
|
import beszel from "./beszel"
|
||||||
@@ -10,10 +11,6 @@ const app = new Hono()
|
|||||||
app.use("*", logger())
|
app.use("*", logger())
|
||||||
app.use("*", cors())
|
app.use("*", cors())
|
||||||
|
|
||||||
app.get("/", (c) => {
|
|
||||||
return c.json({ message: "Hello from Bun + Hono!" })
|
|
||||||
})
|
|
||||||
|
|
||||||
app.get("/api/health", (c) => {
|
app.get("/api/health", (c) => {
|
||||||
return c.json({ status: "ok", timestamp: new Date().toISOString() })
|
return c.json({ status: "ok", timestamp: new Date().toISOString() })
|
||||||
})
|
})
|
||||||
@@ -27,6 +24,12 @@ app.route("/api/tfl", tfl)
|
|||||||
// Mount Beszel routes
|
// Mount Beszel routes
|
||||||
app.route("/api/beszel", beszel)
|
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 {
|
export default {
|
||||||
port: 8000,
|
port: 8000,
|
||||||
fetch: app.fetch,
|
fetch: app.fetch,
|
||||||
|
|||||||
Reference in New Issue
Block a user