t3-code-android-nightly/.repos/alchemy-effect/examples/cloudflare-neon-prisma
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00
..
migrations chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00
src chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00
test chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00
.gitattributes chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00
alchemy.run.ts chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00
package.json chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00
prisma.config.ts chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00
README.md chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00
tsconfig.json chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00

TypeScript-first Prisma and Effect

This example deploys a Cloudflare Worker, Hyperdrive connection, and Neon database. src/prisma/contract.ts is the authoritative schema. The application imports it directly; query types need no generated application imports.

const db = yield* Postgres(connection.connectionString, { contract });
const users = yield* db.orm.public.User.all();

src/Api.ts also derives row validators with makeSchemas(contract) and validates created rows. These are database row schemas, not public API definitions or create inputs. The Arktype bootstrap in src/prisma/validation.ts is required when the native authoring module runs in a Worker.

Run

From the repository root, install dependencies with pnpm install, then:

cd examples/cloudflare-neon-prisma
pnpm deploy
pnpm test
pnpm destroy

Configure Alchemy's Cloudflare and Neon credentials first. The tests deploy real resources and clean them up. Set ALCHEMY_PROFILE=testing when using that profile. The deployment plans and applies Prisma migration packages separately from runtime queries.

Optional standalone schemas

pnpm generate
pnpm generate:watch

prisma.config.ts selects { client: false, schemas: true }. This emits standalone Effect schemas for consumers that should not import the contract authoring code. It does not connect to Neon or migrate a database.

Compare the PSL-first example: it uses the same query API, but authors contract.psl and imports generated makeDatabase.