1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import { EventStream, serve } from "bun";
serve({
port: 3000,
fetch(req) {
return new Response(
new EventStream({
start(controller) {
setTimeout(() => {
controller.send("hi");
// controller.close();
}, 1000);
},
cancel() {
console.log("CANCEL");
},
}),
{
headers: {
"Content-Bruh": "text/bruh",
"Content-Length": "452",
},
},
);
},
});
// // serve({
// // port: 3000,
// // fetch(req) {
// // return new Response(new Blob(["hello world"], { type: "custom/type" }));
// // },
// // });
|