@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 48 lines 1.62 KB
Raw
1 import * as Hetzner from "@alchemy.run/hetzner";
2 import * as Effect from "effect/Effect";
3 import { HttpServerRequest } from "effect/http/HttpServerRequest";
4 import * as HttpServerResponse from "effect/http/HttpServerResponse";
5 import { isolatedProject } from "../../IsolatedProject.ts";
6
7 /**
8 * The isolated consumer project this service is bundled from (see
9 * `test/IsolatedProject.ts`): `main` lives outside the repository, so the
10 * bundle `cwd` resolves none of alchemy's dependencies and the bun
11 * bootstrap's own imports must be anchored by the bundler.
12 */
13 export const project = isolatedProject("hetzner-service", import.meta.filename, [
14 "@alchemy.run/hetzner",
15 ]);
16
17 export const IsolatedBox = Hetzner.Server("IsolatedProjectBox", {
18 serverType: "cpx12",
19 image: "ubuntu-24.04",
20 location: "nbg1",
21 });
22
23 /**
24 * Minimal `Hetzner.Service` served from an isolated project. `/health`
25 * answering 200 proves the generated bootstrap booted under its systemd
26 * unit — with its imports left external bun dies at module load and the
27 * port never answers.
28 */
29 export default class IsolatedProjectApi extends Hetzner.Service<IsolatedProjectApi>()(
30 "IsolatedProjectApi",
31 {
32 server: IsolatedBox,
33 main: project.main,
34 port: 3000,
35 },
36 Effect.gen(function* () {
37 return {
38 fetch: Effect.gen(function* () {
39 const request = yield* HttpServerRequest;
40 const url = new URL(request.url, "http://service");
41 if (url.pathname === "/health") {
42 return yield* HttpServerResponse.json({ ok: true });
43 }
44 return HttpServerResponse.text("hello from isolated project");
45 }),
46 };
47 }),
48 ) {}