-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
38 lines (30 loc) · 1.21 KB
/
server.ts
File metadata and controls
38 lines (30 loc) · 1.21 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
34
35
36
37
38
import { Hono } from "hono";
import { serve } from "@hono/node-server";
import { createServer } from "react-flight-router/server";
import { app as apiApp } from "./server/index.js";
import { startJobProcessor } from "./app/lib/queue.js";
async function main() {
const flightApp = await createServer({
buildDir: "./dist",
workers: { size: 1 },
});
// Create the unified server: API routes first, then flight router for pages
const app = new Hono();
// Mount all API and asset routes (matched before the page catch-all)
app.route("/", apiApp);
// Mount flight router for all page requests (RSC, SSR, actions, static assets)
app.all("*", (c) => flightApp.fetch(c.req.raw));
const server = serve({ fetch: app.fetch, port: 3000 }, (info) => {
console.log(`[Compendus] Server running at http://localhost:${info.port}`);
});
// Disable default timeouts so large file uploads (1GB+ audiobooks) don't get killed
server.setTimeout(0);
(server as any).requestTimeout = 0;
(server as any).headersTimeout = 0;
// Start background job processor (transcription, conversion queue)
startJobProcessor();
}
main().catch((err) => {
console.error("Failed to start server:", err);
process.exit(1);
});