diff --git a/backend/package-lock.json b/backend/package-lock.json index b06152a..5f368e3 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -25,6 +25,7 @@ "@types/node": "^20.14.0", "@types/nodemailer": "^7.0.11", "@types/pg": "^8.11.6", + "@types/ws": "^8.18.1", "tsx": "^4.15.7", "typescript": "^5.4.5" } @@ -657,6 +658,16 @@ "pg-types": "^2.2.0" } }, + "node_modules/@types/ws": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz", + "integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/abstract-logging": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/abstract-logging/-/abstract-logging-2.0.1.tgz", diff --git a/backend/package.json b/backend/package.json index a963e37..892f9aa 100644 --- a/backend/package.json +++ b/backend/package.json @@ -26,6 +26,7 @@ "@types/node": "^20.14.0", "@types/nodemailer": "^7.0.11", "@types/pg": "^8.11.6", + "@types/ws": "^8.18.1", "tsx": "^4.15.7", "typescript": "^5.4.5" } diff --git a/backend/src/routes/ws.ts b/backend/src/routes/ws.ts index 4bbcf07..1404c98 100644 --- a/backend/src/routes/ws.ts +++ b/backend/src/routes/ws.ts @@ -1,6 +1,6 @@ import { FastifyPluginAsync } from 'fastify' import fastifyWebsocket from '@fastify/websocket' -import type { WebSocket } from 'ws' +import type { WebSocket, RawData } from 'ws' // hotel slug → set of connected clients const hotelRooms = new Map>() @@ -18,7 +18,7 @@ const ws: FastifyPluginAsync = async (fastify) => { if (!hotelRooms.has(hotel)) hotelRooms.set(hotel, new Set()) hotelRooms.get(hotel)!.add(socket) - socket.on('message', (raw) => { + socket.on('message', (raw: RawData) => { const data = raw.toString() const peers = hotelRooms.get(hotel) if (!peers) return