| 1 | /** |
| 2 | * Fly.io Managed Postgres + Drizzle, queried from an HTTP Service. |
| 3 | * |
| 4 | * Billed (~$38/mo Basic). |
| 5 | */ |
| 6 | import * as Alchemy from "alchemy"; |
| 7 | import * as Drizzle from "alchemy/Drizzle"; |
| 8 | import * as Fly from "alchemy/Fly"; |
| 9 | import * as Effect from "effect/Effect"; |
| 10 | import * as Layer from "effect/Layer"; |
| 11 | import Api from "./src/api.ts"; |
| 12 | import { Db, Schema } from "./src/shared.ts"; |
| 13 | |
| 14 | export default Alchemy.Stack( |
| 15 | "FlyPostgres", |
| 16 | { |
| 17 | providers: Layer.mergeAll(Fly.providers(), Drizzle.providers()), |
| 18 | state: Alchemy.localState(), |
| 19 | }, |
| 20 | Effect.gen(function* () { |
| 21 | const schema = yield* Schema; |
| 22 | const db = yield* Db; |
| 23 | const api = yield* Api; |
| 24 | |
| 25 | return { |
| 26 | appName: api.appName, |
| 27 | clusterId: db.clusterId, |
| 28 | clusterName: db.name, |
| 29 | region: db.region, |
| 30 | migrations: schema.migrations, |
| 31 | apiUrl: api.url, |
| 32 | }; |
| 33 | }), |
| 34 | ); |