-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathalchemy.run.ts
More file actions
54 lines (47 loc) · 1.17 KB
/
alchemy.run.ts
File metadata and controls
54 lines (47 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
50
51
52
53
54
import alchemy from "alchemy";
import {
D1Database,
DOStateStore,
KVNamespace,
TanStackStart,
} from "alchemy/cloudflare";
const APP_NAME = process.env.APP_NAME ?? "tanstack-start";
const STAGE = process.env.STAGE ?? "dev";
const app = await alchemy(`${APP_NAME}-cloudflare`, {
stage: STAGE,
phase: process.argv.includes("--destroy") ? "destroy" : "up",
stateStore:
process.env.ALCHEMY_STATE_STORE === "cloudflare"
? (scope) =>
new DOStateStore(scope, {
apiKey: alchemy.secret(process.env.CLOUDFLARE_API_KEY),
email: process.env.CLOUDFLARE_EMAIL,
worker: {
name: `${APP_NAME}-state`,
},
})
: undefined,
});
const defaultKv = await KVNamespace(`${APP_NAME}-${STAGE}-kv`, {
title: `${APP_NAME}-${STAGE}-kv`,
adopt: true,
});
const db = await D1Database(`${APP_NAME}-${STAGE}-db`, {
name: `${APP_NAME}-${STAGE}-db`,
adopt: true,
migrationsDir: "src/db/migrations",
primaryLocationHint: "weur",
readReplication: {
mode: "disabled",
},
});
export const website = await TanStackStart(`${APP_NAME}-${STAGE}-website`, {
bindings: {
DEFAULT_KV: defaultKv,
DB: db,
},
});
console.log({
url: website.url,
});
await app.finalize();