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

main
mjs 22 lines 1011 Bytes
Raw
1 // Minimal long-lived dev server for the StaticSite fixture: serves ./src
2 // over HTTP on an ephemeral port and prints its own localhost URL, which
3 // `Command.Dev` extracts from stdout and surfaces as the site's dev `url`.
4 //
5 // `/__dev-env` echoes the DEV_MARKER environment variable so tests can
6 // prove that `dev.env` reached the spawned child process.
7 //
8 // Plain .mjs (not .ts) so the test project's tsc never type-checks it —
9 // it only ever runs under bun as a fixture child process.
10 const server = Bun.serve({
11 port: 0,
12 fetch: async (request) => {
13 const { pathname } = new URL(request.url);
14 if (pathname === "/__dev-env") {
15 return Response.json({ marker: process.env.DEV_MARKER ?? null });
16 }
17 const file = Bun.file(`${process.cwd()}/src${pathname === "/" ? "/index.html" : pathname}`);
18 return (await file.exists()) ? new Response(file) : new Response("not found", { status: 404 });
19 },
20 });
21
22 console.log(`StaticSite fixture dev server: http://localhost:${server.port}`);