Fix TypeScript: add @types/ws and RawData type for WebSocket message

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-17 18:08:14 +03:00
parent 3506105fc1
commit 25b1a96740
3 changed files with 14 additions and 2 deletions

View File

@@ -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<string, Set<WebSocket>>()
@@ -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