1import * as Hetzner from "alchemy/Hetzner";
2import * as Neon from "alchemy/Neon";
3import * as Effect from "effect/Effect";
4
5export 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 */
11export 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 */
21export 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 */
31export const NeonBranch = Effect.gen(function* () {
32 const project = yield* NeonProject;
33 return yield* Neon.Branch("NotesBranch", { project });
34});