| 1 | import * as Fly from "@/Fly"; |
| 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 sprite 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("fly-sprite", import.meta.filename); |
| 14 | |
| 15 | /** |
| 16 | * Minimal `Fly.Sprite` served from an isolated project. `/health` answering |
| 17 | * 200 proves the generated bootstrap booted — with its imports left external |
| 18 | * bun dies at module load and the sprite URL never answers. |
| 19 | */ |
| 20 | export default class IsolatedProjectBox extends Fly.Sprite<IsolatedProjectBox>()( |
| 21 | "IsolatedProjectBox", |
| 22 | { |
| 23 | main: project.main, |
| 24 | urlAuth: "public", |
| 25 | port: 3000, |
| 26 | }, |
| 27 | Effect.gen(function* () { |
| 28 | return { |
| 29 | fetch: Effect.gen(function* () { |
| 30 | const request = yield* HttpServerRequest; |
| 31 | const url = new URL(request.url, "http://sprite"); |
| 32 | if (url.pathname === "/health") { |
| 33 | return yield* HttpServerResponse.json({ ok: true }); |
| 34 | } |
| 35 | return yield* HttpServerResponse.json({ ok: true }); |
| 36 | }), |
| 37 | }; |
| 38 | }), |
| 39 | ) {} |