NestJS · Middle · Question 39 of 75
What is a WebSocket gateway in Nest?
@WebSocketGateway()
export class ChatGateway {
@SubscribeMessage("message")
handle(@MessageBody() text: string) {}
}- 1A REST controller for chat
- ✓Correct answer: A provider that handles WebSocket messages with decorators, using Socket.IO or
wsadapters - 3An HTTP reverse proxy
Explanation
Guards, pipes, interceptors and filters work in gateways too. With several instances, use a Redis adapter to broadcast.