| 1 | import * as Hetzner from "alchemy/Hetzner"; |
| 2 | import * as Neon from "alchemy/Neon"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | |
| 5 | export const API_PORT = 3001; |
| 6 | |
| 7 | /** |
| 8 | * One cpx12 both the API unit and the Website static server share. |
| 9 | * Matches `Hetzner.Website` auto-create (`cpx12` / `ubuntu-24.04` / `fsn1`). |
| 10 | */ |
| 11 | export const Box = Hetzner.Server("Box", { |
| 12 | serverType: "cpx12", |
| 13 | image: "ubuntu-24.04", |
| 14 | location: "fsn1", |
| 15 | }); |
| 16 | |
| 17 | /** |
| 18 | * Hetzner has no managed Postgres. Neon is the Alchemy-managed database |
| 19 | * the API Service connects to over HTTPS from the Server. |
| 20 | */ |
| 21 | export const NeonProject = Neon.Project("NotesDb", { |
| 22 | region: "aws-us-east-1", |
| 23 | }); |
| 24 | |
| 25 | /** |
| 26 | * Feature branch of {@link NeonProject}. Yield the project first so |
| 27 | * Branch reconcile sees a resolved `{ projectId }` — a module-scope |
| 28 | * `project: NeonProject` is planned in parallel and fails with |
| 29 | * "Invalid Neon project source". |
| 30 | */ |
| 31 | export const NeonBranch = Effect.gen(function* () { |
| 32 | const project = yield* NeonProject; |
| 33 | return yield* Neon.Branch("NotesBranch", { project }); |
| 34 | }); |