1import * as Cloudflare from "@/Cloudflare/index.ts";
2import * as Neon from "@/Neon/index.ts";
3import * as Effect from "effect/Effect";
4
5/**
6 * Shared Neon Postgres origin + Hyperdrive Connection bound by both
7 * binding-test workers (effect-worker via `Cloudflare.Hyperdrive.Connect`
8 * and async-worker via `env: { HD: Connection }`). Because both workers
9 * bind this same Connection, the metadata they read back over `fetch`
10 * (host / port / user / database / connection string) must agree with the
11 * Neon origin that fronts it.
12 */
13export const HyperdriveConnection = Effect.gen(function* () {
14 const project = yield* Neon.Project("HyperdriveBindingProject");
15 const connection = yield* Cloudflare.Hyperdrive.Connection(
16 "HyperdriveBindingConnection",
17 {
18 origin: project.origin,
19 },
20 );
21 return { project, connection };
22});