-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
33 lines (26 loc) · 1 KB
/
Copy pathserver.ts
File metadata and controls
33 lines (26 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { Hono } from "hono";
import { serve } from "@hono/node-server";
import { serveStatic } from "@hono/node-server/serve-static";
import { createServer } from "react-flight-router/server";
import { app as apiApp } from "./app/api/server.ts";
async function main() {
const flightApp = await createServer({
buildDir: "./dist",
});
// Create a parent app so API routes are registered before the RSC catch-all
const app = new Hono();
// API routes (must come before the flight router catch-all)
app.route("/", apiApp);
// Public static files (favicon, manifest, icons)
app.use("/*", serveStatic({ root: "./public" }));
// Flight router handles RSC, SSR, assets, and server actions
app.route("/", flightApp);
const port = Number(process.env.PORT) || 3000;
serve({ fetch: app.fetch, port }, (info) => {
console.log(`Gardeneus running at http://localhost:${info.port}`);
});
}
main().catch((err) => {
console.error("Failed to start server:", err.stack || err);
process.exit(1);
});