|
1 | 1 | /// <reference types="@types/node" /> |
2 | 2 |
|
3 | 3 | import alchemy from "alchemy"; |
4 | | -import { |
5 | | - D1Database, |
6 | | - DurableObjectNamespace, |
7 | | - Vite, |
8 | | - Worker, |
9 | | -} from "alchemy/cloudflare"; |
| 4 | +import { D1Database, DurableObjectNamespace, Vite } from "alchemy/cloudflare"; |
10 | 5 |
|
11 | 6 | const app = await alchemy("cloudflare-livestore"); |
12 | 7 |
|
13 | | -export const server = await Worker("server", { |
14 | | - name: `${app.name}-${app.stage}-server`, |
15 | | - entrypoint: "src/cf-worker/index.ts", |
| 8 | +const db = await D1Database("db", { |
| 9 | + name: `${app.name}-${app.stage}-livestore`, |
| 10 | + adopt: true, |
| 11 | +}); |
| 12 | + |
| 13 | +export const server = await Vite("server", { |
| 14 | + assets: "dist", |
| 15 | + main: "src/livestore/server.ts", |
| 16 | + wrangler: false, |
| 17 | + compatibility: "node", |
16 | 18 | bindings: { |
17 | | - DB: await D1Database("db", { |
18 | | - name: `${app.name}-${app.stage}-livestore-sync-cf-demo`, |
19 | | - adopt: true, |
20 | | - }), |
| 19 | + DB: db, |
21 | 20 | WEBSOCKET_SERVER: DurableObjectNamespace("websocket-server", { |
22 | 21 | className: "WebSocketServer", |
23 | 22 | }), |
24 | 23 | }, |
25 | | - compatibilityFlags: ["nodejs_compat"], |
26 | | - compatibilityDate: "2025-05-08", |
27 | | -}); |
28 | | - |
29 | | -export const client = await Vite("client", { |
30 | | - assets: "dist", |
31 | | - command: "bun vite build", |
32 | | - dev: { |
33 | | - command: "bun vite --force", |
34 | | - }, |
35 | | - env: { |
36 | | - VITE_LIVESTORE_SYNC_URL: server.url!, |
37 | | - }, |
38 | | - wrangler: false, |
39 | 24 | }); |
40 | 25 |
|
41 | 26 | console.log(`server.url: ${server.url}`); |
|
0 commit comments