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:
ka-official
2026-03-25 21:08:30 +00:00
parent 402311e6ec
commit 02762acc59
5 changed files with 22 additions and 360 deletions

View File

@@ -1,46 +1,9 @@
import type { Express } from "express";
import { createServer, type Server } from "http";
import { WebSocketServer } from "ws";
import fs from "fs";
import path from "path";
import { handleMessage, handleClose } from "./buzzer-ws";
export async function registerRoutes(
httpServer: Server,
app: Express
_app: Express
): Promise<Server> {
// Serve buzzer static files
const publicDir = path.resolve(process.cwd(), "src/public");
app.get("/", (_req, res) => {
res.setHeader("Content-Type", "text/html; charset=utf-8");
res.send(fs.readFileSync(path.join(publicDir, "index.html"), "utf-8"));
});
app.get("/styles.css", (_req, res) => {
res.setHeader("Content-Type", "text/css");
res.send(fs.readFileSync(path.join(publicDir, "styles.css"), "utf-8"));
});
app.get("/script.js", (_req, res) => {
res.setHeader("Content-Type", "text/javascript");
res.send(fs.readFileSync(path.join(publicDir, "script.js"), "utf-8"));
});
// WebSocket server for buzzer
const wss = new WebSocketServer({ server: httpServer, path: "/ws" });
wss.on("connection", (ws) => {
ws.on("message", (data) => {
if (typeof data === "string") {
handleMessage(ws, data);
} else {
handleMessage(ws, data.toString());
}
});
ws.on("close", () => handleClose(ws));
ws.on("error", () => { try { ws.close(); } catch {} });
});
return httpServer;
}