forked from supermemoryai/cloudflare-saas-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
28 lines (23 loc) · 692 Bytes
/
server.ts
File metadata and controls
28 lines (23 loc) · 692 Bytes
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
import { Hono } from "hono";
import { auth } from "~/utils/auth.server";
import { createCloudflareContext, setupRemixHandler } from "~/utils/handlers";
const app = new Hono<{ Bindings: Env }>();
app.get("/hello", (c) => {
return c.text("Hello World");
});
app.all("*", async (c) => {
try {
const handleRemixRequest = setupRemixHandler();
const loadContext = createCloudflareContext(
c.req.raw,
c.env,
c.executionCtx as ExecutionContext,
);
const response = await handleRemixRequest(c.req.raw, loadContext);
return response;
} catch (error) {
console.error(error);
return new Response("An unexpected error occurred", { status: 500 });
}
});
export default app;