1/**
2 * Fly.io Managed Postgres + Drizzle, queried from an HTTP Service.
3 *
4 * Billed (~$38/mo Basic).
5 */
6import * as Alchemy from "alchemy";
7import * as Drizzle from "alchemy/Drizzle";
8import * as Fly from "alchemy/Fly";
9import * as Effect from "effect/Effect";
10import * as Layer from "effect/Layer";
11import Api from "./src/api.ts";
12import { Db, Schema } from "./src/shared.ts";
13
14export 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);