Files
image-gateway/tests/fixture/server.js

31 lines
750 B
JavaScript
Raw Normal View History

const image = Buffer.from(
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGklEQVR4nGP8z8Dwn4ECwESJ5lEDRgYAtP4CHcB7d7gAAAAASUVORK5CYII=",
"base64",
);
Bun.serve({
port: 8080,
fetch(request) {
const url = new URL(request.url);
if (url.pathname === "/health") {
return new Response("ok", {
headers: { "content-type": "text/plain" },
});
}
if (url.pathname === "/image.png") {
return new Response(image, {
headers: {
"cache-control": "public, max-age=31536000",
"content-length": String(image.length),
"content-type": "image/png",
etag: '"fixture-image-v1"',
},
});
}
return new Response("not found", { status: 404 });
},
});