@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

main
ts 23 lines 919 Bytes
Raw
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 // #region show
9 /** The Database module's interface: a SQL client. */
10 export const Database = SqlClient.SqlClient;
11
12 export const DatabaseLive = Layer.unwrap(
13 Effect.gen(function* () {
14 // #region db
15 const db = yield* Neon.Project("Db", { migrations: "./migrations" });
16 // #endregion db
17 const pool = yield* Cloudflare.Hyperdrive.Connection("Pool", { origin: db.origin });
18 const connection = yield* Cloudflare.Hyperdrive.Connect(pool);
19 return Postgres.PostgresLayer({ url: connection.connectionString });
20 }),
21 ) /*hide*/
22 .pipe(Layer.provide(Cloudflare.Hyperdrive.ConnectBinding)); /*end*/
23 // #endregion show