-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.ts
46 lines (40 loc) · 1.12 KB
/
server.ts
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
39
40
41
42
43
44
45
46
import type {
SessionStorage} from "@remix-run/cloudflare";
import {
createWorkersKVSessionStorage,
logDevReady
} from "@remix-run/cloudflare";
import { createPagesFunctionHandler } from "@remix-run/cloudflare-pages";
import * as build from "@remix-run/dev/server-build";
type SessionData = {};
type SessionFlashData = {};
interface Env {
VGMUSIC: KVNamespace;
sessionStorage: SessionStorage<SessionData, SessionFlashData>;
}
declare module "@remix-run/server-runtime" {
interface AppLoadContext extends Env {}
}
if (process.env.NODE_ENV === "development") {
logDevReady(build);
}
export const onRequest = createPagesFunctionHandler({
build,
getLoadContext: (context) => ({
env: context.env,
VGMUSIC: context.env.VGMUSIC,
sessionStorage: createWorkersKVSessionStorage({
kv: context.env.VGMUSIC,
cookie: {
secure: process.env.NODE_ENV === "production",
secrets: [context.env.VGMUSIC_SECRET],
sameSite: "lax",
path: "/",
maxAge: 60 * 60 * 24 * 30,
httpOnly: true,
name: "__session",
},
}),
}),
mode: process.env.NODE_ENV,
});