Overview
The notifications/gateway/notifications.gateway.ts file exists but is unimplemented — notifications are REST-poll-only. Members miss time-sensitive updates (booking confirmations, payment events) without a manual page refresh.
Context
NotificationType enum: backend/src/notifications/enums/notification-type.enum.ts
CreateNotificationProvider: backend/src/notifications/providers/create-notification.provider.ts — persists notifications via REST
- Gateway file already scaffolded at:
backend/src/notifications/gateway/notifications.gateway.ts
@nestjs/websockets and socket.io are available in the NestJS ecosystem
Tasks
Files to Modify / Create
backend/src/notifications/gateway/notifications.gateway.ts
backend/src/notifications/notifications.module.ts
backend/src/notifications/providers/create-notification.provider.ts
Overview
The
notifications/gateway/notifications.gateway.tsfile exists but is unimplemented — notifications are REST-poll-only. Members miss time-sensitive updates (booking confirmations, payment events) without a manual page refresh.Context
NotificationTypeenum:backend/src/notifications/enums/notification-type.enum.tsCreateNotificationProvider:backend/src/notifications/providers/create-notification.provider.ts— persists notifications via RESTbackend/src/notifications/gateway/notifications.gateway.ts@nestjs/websocketsandsocket.ioare available in the NestJS ecosystemTasks
@WebSocketGateway()with CORS config innotifications.gateway.tshandleConnection()authenticates the socket via JWT from the handshakeAuthorizationheader; disconnect unauthenticated sockets immediatelyhandleDisconnect()removes the socket from the user's roomnotifyUser(userId, payload)method that emits to a user-specific room (e.g.room:${userId})notifyUser()fromCreateNotificationProviderafter persisting each notification to the databaseNotificationsModuleFiles to Modify / Create
backend/src/notifications/gateway/notifications.gateway.tsbackend/src/notifications/notifications.module.tsbackend/src/notifications/providers/create-notification.provider.ts