fix: register @fastify/websocket globally so /ws/agent route works
setupAgentWsRoute was called outside the encapsulated wsRoutes plugin scope where @fastify/websocket was registered. Register the plugin at the root level and convert setupAgentWsRoute to FastifyPluginAsync. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { FastifyPluginAsync } from 'fastify'
|
||||
import fastifyWebsocket from '@fastify/websocket'
|
||||
import type { SocketStream } from '@fastify/websocket'
|
||||
import type { RawData } from 'ws'
|
||||
|
||||
@@ -18,8 +17,6 @@ export function broadcast(hotelSlug: string, message: object) {
|
||||
const PING_INTERVAL_MS = 25_000 // ping every 25s — keeps nginx proxy_read_timeout alive
|
||||
|
||||
const ws: FastifyPluginAsync = async (fastify) => {
|
||||
await fastify.register(fastifyWebsocket)
|
||||
|
||||
fastify.get<{ Querystring: { hotel?: string } }>(
|
||||
'/ws',
|
||||
{ websocket: true },
|
||||
|
||||
Reference in New Issue
Block a user