The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Cloudflare from "@alchemy.run/cloudflare"; |
| 2 | import * as Neon from "@alchemy.run/neon"; |
| 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* Neon.Project("Db"); |
| 11 | const db = yield* Neon.Branch("Db", { project: database }); |
| 12 | const pool = yield* Cloudflare.Hyperdrive.Connection("Pool", { origin: db.origin }); |
| 13 | const connection = yield* Cloudflare.Hyperdrive.Connect(pool); |
| 14 | return Postgres.PostgresLayer({ url: connection.connectionString }); |
| 15 | }), |
| 16 | ) /*hide*/ |
| 17 | .pipe(Layer.provide(Cloudflare.Hyperdrive.ConnectBinding)); /*end*/ |
| 18 | // #endregion show |