1import * as Alchemy from "alchemy";
2import * as Hetzner from "alchemy/Hetzner";
3import * as Neon from "alchemy/Neon";
4import * as Output from "alchemy/Output";
5import * as Effect from "effect/Effect";
6import * as Layer from "effect/Layer";
7import Api from "./src/api.ts";
8import { Box, NeonBranch, NeonProject } from "./src/shared.ts";
9
10export default Alchemy.Stack(
11 "HetznerWebsiteViteExample",
12 {
13 providers: Layer.mergeAll(Hetzner.providers(), Neon.providers()),
14 state: Alchemy.localState(),
15 },
16 Effect.gen(function* () {
17 const server = yield* Box;
18 const project = yield* NeonProject;
19 const branch = yield* NeonBranch;
20 const api = yield* Api;
21 const web = yield* Hetzner.Website.Vite("Web", {
22 server,
23 env: {
24 VITE_API_URL: Output.map(api.url, (url) => url ?? ""),
25 },
26 memo: {
27 include: ["index.html", "src/**", "package.json", "vite.config.ts"],
28 },
29 });
30
31 return {
32 url: web.url,
33 apiUrl: api.url,
34 serverId: server.serverId,
35 ipv4: server.ipv4,
36 neonProjectId: project.projectId,
37 neonBranchId: branch.branchId,
38 };
39 }),
40);