Integrate buzzer functionality into Bun server and update workflows
Reverts Express server setup for the buzzer, migrates all functionality to a Bun server, and updates the workflow to execute the Bun server directly. Replit-Commit-Author: Agent Replit-Commit-Session-Id: f3ac8eb3-f610-4678-ab6e-ebf900098be4 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: c1942b0a-0cf4-4ca9-9b5f-f80287c102f2 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/d4b7863b-f7b2-425c-a9b5-ad7bd1885e9d/f3ac8eb3-f610-4678-ab6e-ebf900098be4/N1qS6qo Replit-Helium-Checkpoint-Created: true
This commit is contained in:
@@ -1,21 +1,30 @@
|
||||
import { readFileSync } from "fs";
|
||||
import { handleMessage, handleClose } from "./ws-handler";
|
||||
|
||||
const HTML = readFileSync("./src/public/index.html", "utf-8");
|
||||
const CSS = readFileSync("./src/public/styles.css", "utf-8");
|
||||
const JS = readFileSync("./src/public/script.js", "utf-8");
|
||||
const PORT = parseInt(process.env.PORT || "5000", 10);
|
||||
|
||||
const server = Bun.serve({
|
||||
port: 3009,
|
||||
port: PORT,
|
||||
hostname: "0.0.0.0",
|
||||
fetch(req, server) {
|
||||
const url = new URL(req.url);
|
||||
if (url.pathname === "/ws") {
|
||||
if (!server.upgrade(req)) return new Response("WS upgrade failed", { status: 400 });
|
||||
return undefined as any;
|
||||
}
|
||||
if (url.pathname === "/styles.css") return new Response(CSS, { headers: { "Content-Type": "text/css" } });
|
||||
if (url.pathname === "/script.js") return new Response(JS, { headers: { "Content-Type": "text/javascript" } });
|
||||
return new Response(HTML, { headers: { "Content-Type": "text/html; charset=utf-8" } });
|
||||
if (url.pathname === "/styles.css") {
|
||||
return new Response(readFileSync("./src/public/styles.css", "utf-8"), {
|
||||
headers: { "Content-Type": "text/css" },
|
||||
});
|
||||
}
|
||||
if (url.pathname === "/script.js") {
|
||||
return new Response(readFileSync("./src/public/script.js", "utf-8"), {
|
||||
headers: { "Content-Type": "text/javascript" },
|
||||
});
|
||||
}
|
||||
return new Response(readFileSync("./src/public/index.html", "utf-8"), {
|
||||
headers: { "Content-Type": "text/html; charset=utf-8" },
|
||||
});
|
||||
},
|
||||
websocket: {
|
||||
perMessageDeflate: true,
|
||||
@@ -26,4 +35,4 @@ const server = Bun.serve({
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`\x1b[32m[BUZZER]\x1b[0m → \x1b[36mhttp://localhost:${server.port}\x1b[0m`);
|
||||
console.log(`\x1b[32m[BUZZER]\x1b[0m → \x1b[36mhttp://localhost:${server.port}\x1b[0m`);
|
||||
|
||||
Reference in New Issue
Block a user