# หาบั๊กให้เจอ: Node.js / NestJS > โค้ดหนึ่งชิ้น หาบั๊กให้เจอ หรือพิสูจน์ว่าไม่มีบั๊ก ชาเลนจ์ประจำวัน: 2026-08-19 (UTC) · Mid-Level ```typescript import { WebSocketGateway, SubscribeMessage, MessageBody, ConnectedSocket } from '@nestjs/websockets'; import { Socket } from 'socket.io'; import { MessagesService } from './messages.service'; @WebSocketGateway({ namespace: 'chat' }) export class ChatGateway { constructor(private readonly messages: MessagesService) {} @SubscribeMessage('joinRoom') async joinRoom( @ConnectedSocket() client: Socket, @MessageBody() data: { roomId: string }, ) { client.join(data.roomId); const history = await this.messages.getRoomHistory(data.roomId); client.emit('history', history); } } ``` ## คำตัดสินของคุณ - ช่องโหว่ความปลอดภัย - บั๊กเชิงตรรกะ - สไตล์โค้ด - ไม่มีปัญหา วันละหนึ่งครั้ง คำตอบจะแสดงทันทีหลังจากนั้น --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/daily/node-nestjs