forked from supermemoryai/cloudflare-saas-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandlers.ts
More file actions
26 lines (24 loc) · 842 Bytes
/
handlers.ts
File metadata and controls
26 lines (24 loc) · 842 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
import { createRequestHandler, type ServerBuild } from "@remix-run/cloudflare";
import * as build from "./build/server";
import { getLoadContext } from "./load-context";
// Abstract Remix handler setup
export const setupRemixHandler = () => {
return createRequestHandler(build as unknown as ServerBuild);
};
// Create context for Remix from Cloudflare env
export const createCloudflareContext = (request: Request, env: Env, ctx: ExecutionContext) => {
return getLoadContext({
request,
context: {
cloudflare: {
cf: request.cf,
ctx: {
waitUntil: ctx.waitUntil.bind(ctx),
passThroughOnException: ctx.passThroughOnException.bind(ctx),
},
caches,
env,
},
},
});
};