The best way to control Claude Code, Codex and more from any computer or phone

main
ts 21 lines 887 Bytes
Raw
1 import * as Cloudflare from "@alchemy.run/cloudflare";
2 import * as Planetscale from "@alchemy.run/planetscale";
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* Planetscale.PostgresDatabase("Db", {
11 clusterSize: "PS_10",
12 arch: "arm",
13 });
14 const db = yield* Planetscale.PostgresRole("Db", { database, inheritedRoles: ["postgres"] });
15 const pool = yield* Cloudflare.Hyperdrive.Connection("Pool", { origin: db.origin });
16 const connection = yield* Cloudflare.Hyperdrive.Connect(pool);
17 return Postgres.PostgresLayer({ url: connection.connectionString });
18 }),
19 ) /*hide*/
20 .pipe(Layer.provide(Cloudflare.Hyperdrive.ConnectBinding)); /*end*/
21 // #endregion show