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