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, 07:15 UTC
| 1 | import * as Cloudflare from "@alchemy.run/cloudflare"; |
| 2 | import * as Prisma from "@alchemy.run/prisma"; |
| 3 | import * as Postgres from "@alchemy.run/sql/Postgres"; |
| 4 | import * as Effect from "effect/Effect"; |
| 5 | import * as Layer from "effect/Layer"; |
| 6 | |
| 7 | // #region show |
| 8 | export const DatabaseLive = Layer.unwrap( |
| 9 | Effect.gen(function* () { |
| 10 | const database = yield* Prisma.Postgres("Db", { project: "chat" }); |
| 11 | const db = yield* Prisma.Connection("Db", { database }); |
| 12 | const pool = yield* Cloudflare.Hyperdrive.Connection("Pool", { |
| 13 | origin: db.origin.as<Prisma.PostgresOrigin>(), |
| 14 | }); |
| 15 | const connection = yield* Cloudflare.Hyperdrive.Connect(pool); |
| 16 | return Postgres.PostgresLayer({ url: connection.connectionString }); |
| 17 | }), |
| 18 | ) /*hide*/ |
| 19 | .pipe(Layer.provide(Cloudflare.Hyperdrive.ConnectBinding)); /*end*/ |
| 20 | // #endregion show |