mirror of
https://github.com/LukeHagar/crossws.git
synced 2025-12-06 04:19:26 +00:00
20 lines
472 B
TypeScript
20 lines
472 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, indexHTMLURL } from "./_common";
|
|
|
|
const adapter = createDemo(bunAdapter);
|
|
|
|
Bun.serve({
|
|
port: 3001,
|
|
fetch(req, server) {
|
|
if (server.upgrade(req)) {
|
|
return;
|
|
}
|
|
return new Response(Bun.file(indexHTMLURL), {
|
|
headers: { "Content-Type": "text/html" },
|
|
});
|
|
},
|
|
websocket: adapter.websocket,
|
|
});
|