* Convert an embedded web UI map (path → bunfs path) into Bun.serve routes. * The embedded map is generated by the CLI build step using `with { type: "file" }`.
(embedded: Record<string, string>)
| 85 | * The embedded map is generated by the CLI build step using `with { type: "file" }`. |
| 86 | */ |
| 87 | function embeddedToStaticRoutes(embedded: Record<string, string>): Record<string, StaticHandler> { |
| 88 | const routes: Record<string, StaticHandler> = {}; |
| 89 | for (const [key, bunfsPath] of Object.entries(embedded)) { |
| 90 | const file = Bun.file(bunfsPath); |
| 91 | routes[`/${key}`] = () => |
| 92 | key === "index.html" |
| 93 | ? htmlResponse(file) |
| 94 | : new Response(file, { |
| 95 | headers: { |
| 96 | "content-type": file.type || "application/octet-stream", |
| 97 | }, |
| 98 | }); |
| 99 | } |
| 100 | return routes; |
| 101 | } |
| 102 | |
| 103 | // --------------------------------------------------------------------------- |
| 104 | // Dev mode: spawn vite as a child and proxy non-API requests to it |
no test coverage detected