@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
mjs 26 lines 1.04 KB
Raw
1 // Long-lived dev server for the AWS StaticSite. `alchemy dev` spawns it as
2 // a `Command.Dev` child inside the provider sidecar and reads the URL it
3 // prints. The stress suite pins PORT so the address survives every restart,
4 // and reads SITE_MARKER back over `/__dev-env` to prove that a change to
5 // `dev.env` actually RESTARTED the child rather than leaving the old one.
6 //
7 // Plain .mjs so the repo's tsc never type-checks it.
8 const port = Number(process.env.PORT ?? 0);
9 const server = Bun.serve({
10 port,
11 fetch: async (request) => {
12 const { pathname } = new URL(request.url);
13 if (pathname === "/__dev-env") {
14 return Response.json({
15 marker: process.env.SITE_MARKER ?? null,
16 pid: process.pid,
17 });
18 }
19 const file = Bun.file(
20 `${import.meta.dirname}/site${pathname.endsWith("/") ? `${pathname}index.html` : pathname}`,
21 );
22 return (await file.exists()) ? new Response(file) : new Response("not found", { status: 404 });
23 },
24 });
25
26 console.log(`AWS StaticSite dev server: http://localhost:${server.port}`);