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
| 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 | import * as SqlClient from "effect/sql/SqlClient"; |
| 7 | |
| 8 | // The Database module built up line by line (Db.ts is the finished file). |
| 9 | // #region show |
| 10 | /** The Database module's interface: a SQL client. */ |
| 11 | export const Database = SqlClient.SqlClient; |
| 12 | |
| 13 | export const DatabaseLive = Layer.unwrap( |
| 14 | Effect.gen(function* () { |
| 15 | const db = yield* Neon.Project("Db", { migrations: "./migrations" }); |
| 16 | // #region pool |
| 17 | const pool = yield* Cloudflare.Hyperdrive.Connection("Pool", { origin: db.origin }); |
| 18 | // #endregion pool |
| 19 | // #region connect |
| 20 | const connection = yield* Cloudflare.Hyperdrive.Connect(pool); |
| 21 | // #endregion connect |
| 22 | // #region ret |
| 23 | return Postgres.PostgresLayer({ url: connection.connectionString }); |
| 24 | // #endregion ret |
| 25 | }), |
| 26 | ) /*hide*/ |
| 27 | .pipe(Layer.provide(Cloudflare.Hyperdrive.ConnectBinding)); /*end*/ |
| 28 | // #endregion show |