import { createServer } from "node:http"; import { readFile } from "node:fs/promises"; import { fileURLToPath } from "node:url"; import { dirname, join } from "node:path"; const dir = join(dirname(fileURLToPath(import.meta.url)), "fixtures", "images"); createServer(async (req, res) => { const name = (req.url || "").replace(/^\//, "").split("?")[0]; if (name === "good.png" || name === "tiny.png") { try { const buf = await readFile(join(dir, name)); res.writeHead(200, { "Content-Type": "image/png" }); res.end(buf); return; } catch { /* fallthrough */ } } res.writeHead(404); res.end(); }).listen(8799, "127.0.0.1");