1import * as Alchemy from "alchemy";
2import * as Cloudflare from "alchemy/Cloudflare";
3import * as Drizzle from "alchemy/Drizzle";
4import * as Planetscale from "alchemy/Planetscale";
5import * as Effect from "effect/Effect";
6import * as Layer from "effect/Layer";
7
8import Api from "./src/Api.ts";
9import { Hyperdrive, PlanetscaleDb } from "./src/Db.ts";
10
11export default Alchemy.Stack(
12 "CloudflarePlanetscalePostgresDrizzleExample",
13 {
14 providers: Layer.mergeAll(
15 Cloudflare.providers(),
16 Drizzle.providers(),
17 Planetscale.providers(),
18 ),
19 state: Alchemy.localState(),
20 },
21 Effect.gen(function* () {
22 const { database, branch } = yield* PlanetscaleDb;
23 const hd = yield* Hyperdrive;
24 const api = yield* Api;
25
26 return {
27 url: api.url.as<string>(),
28 databaseId: database.id,
29 branchName: branch.name,
30 hyperdriveId: hd.hyperdriveId,
31 };
32 }),
33);