Переработаны роутеры приложения

Переписано APi WebSocket для работы с новыми роутерами
This commit is contained in:
2025-10-03 17:11:31 +03:00
parent d75fb7ec3d
commit 6ec6523d71
54 changed files with 2593 additions and 3749 deletions

25
ws/routes/message.js Normal file
View File

@@ -0,0 +1,25 @@
const { updateApartment } = require("../services/apartments.service");
const { updateBuilding } = require("../services/buildings.service");
const { updateStand } = require("../services/stand.service");
const { broadcast } = require("../utils/broadcaster");
module.exports = async (wss, ws, message) => {
try {
switch (message.type) {
case "apartment":
await updateApartment(ws.user, message.data);
break;
case "building":
await updateBuilding(ws.user, message.data);
break;
case "stand":
await updateStand(ws.user, message.data);
break;
default:
return ws.send(JSON.stringify({ error: `Unknown message type: ${message.type}` }));
}
broadcast(wss, message);
} catch (err) {
ws.send(JSON.stringify({ error: err.message }));
}
};