-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathalchemy.run.ts
More file actions
49 lines (42 loc) · 1.17 KB
/
alchemy.run.ts
File metadata and controls
49 lines (42 loc) · 1.17 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
39
40
41
42
43
44
45
46
47
48
49
import alchemy from "alchemy"
import { Website, D1Database, KVNamespace } from "alchemy/cloudflare"
const APP_NAME = "fullstack-cf-example"
const app = await alchemy(APP_NAME, {
phase: process.argv[2] === "destroy" ? "destroy" : "up",
stage: process.argv[3],
quiet: process.argv.includes("--quiet"),
password: process.env.SECRET_ALCHEMY_PASSPHRASE,
})
const kv = await KVNamespace("site-sessions-storage", {
title: `${APP_NAME}-site-sessions-storage`,
adopt: true,
})
const db = await D1Database("site-users-db", {
name: `${APP_NAME}-site-users-db`,
adopt: true,
migrationsDir: "src/db/migrations",
primaryLocationHint: "wnam",
readReplication: {
mode: "auto",
},
})
export const site = await Website("site", {
name: `${APP_NAME}-site`,
command: "bun clean && bun run build",
main: "dist/worker/worker.js",
assets: "dist/client",
wrangler: {
main: "src/worker.tsx",
},
compatibilityFlags: ["nodejs_compat"],
observability: {
enabled: true,
},
bindings: {
DB: db,
SESSIONS_KV: kv,
BETTER_AUTH_SECRET: alchemy.secret(process.env.BETTER_AUTH_SECRET),
},
})
console.log(`➜ Cloudflare: ${site.url}`)
await app.finalize()