Bun 에서 Response 객체는 Node.js Readable 를 허용합니다.
Bun 의 Response 객체는 바디로 모든 async iterable 을 허용하기 때문에 작동합니다. Node.js 스트림은 async iterable 이므로 Response 에 직접 전달할 수 있습니다.
ts
import { Readable } from "stream";
import { serve } from "bun";
serve({
port: 3000,
fetch(req) {
return new Response(Readable.from(["Hello, ", "world!"]), {
headers: { "Content-Type": "text/plain" },
});
},
});