Files
crossws/playground/bun.ts
2024-01-29 17:31:21 +01:00

20 lines
491 B
TypeScript

// You can run this demo using `bun --bun ./bun.ts` or `npm run play:bun` in repo
import bunAdapter from "../src/adapters/bun";
import { createDemo, getIndexHTML } from "./_common";
const adapter = createDemo(bunAdapter);
Bun.serve({
port: 3001,
websocket: adapter.websocket,
async fetch(req, server) {
if (server.upgrade(req)) {
return;
}
return new Response(await getIndexHTML({ name: "bun" }), {
headers: { "Content-Type": "text/html" },
});
},
});