@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
md 45 lines 1.52 KB
Rendered Raw
1 # TypeScript-first Prisma and Effect
2
3 This example deploys a Cloudflare Worker, Hyperdrive connection, and Neon database.
4 `src/prisma/contract.ts` is the authoritative schema. The application imports it
5 directly; query types need no generated application imports.
6
7 ```ts
8 const db = yield* Postgres(connection.connectionString, { contract });
9 const users = yield* db.orm.public.User.all();
10 ```
11
12 `src/Api.ts` also derives row validators with `makeSchemas(contract)` and validates
13 created rows. These are database row schemas, not public API definitions or create
14 inputs. The Arktype bootstrap in `src/prisma/validation.ts` is required when the
15 native authoring module runs in a Worker.
16
17 ## Run
18
19 From the repository root, install dependencies with `pnpm install`, then:
20
21 ```sh
22 cd examples/cloudflare-neon-prisma
23 pnpm deploy
24 pnpm test
25 pnpm destroy
26 ```
27
28 Configure Alchemy's Cloudflare and Neon credentials first. The tests deploy real
29 resources and clean them up. Set `ALCHEMY_PROFILE=testing` when using that profile.
30 The deployment plans and applies Prisma migration packages separately from runtime
31 queries.
32
33 ## Optional standalone schemas
34
35 ```sh
36 pnpm generate
37 pnpm generate:watch
38 ```
39
40 `prisma.config.ts` selects `{ client: false, schemas: true }`. This emits standalone
41 Effect schemas for consumers that should not import the contract authoring code.
42 It does not connect to Neon or migrate a database.
43
44 Compare [the PSL-first example](../cloudflare-neon-prisma-psl): it uses the same
45 query API, but authors `contract.psl` and imports generated `makeDatabase`.