ミドル
2026年8月19日バグを見つけろ:Node.js / NestJS
コードは1つ。バグを見つけるか、バグがないことを示してください。
typescript
1import { WebSocketGateway, SubscribeMessage, MessageBody, ConnectedSocket } from '@nestjs/websockets';
2import { Socket } from 'socket.io';
3import { MessagesService } from './messages.service';
4
5@WebSocketGateway({ namespace: 'chat' })
6export class ChatGateway {
7 constructor(private readonly messages: MessagesService) {}
8
9 @SubscribeMessage('joinRoom')
10 async joinRoom(
11 @ConnectedSocket() client: Socket,
12 @MessageBody() data: { roomId: string },
13 ) {
14 client.join(data.roomId);
15 const history = await this.messages.getRoomHistory(data.roomId);
16 client.emit('history', history);
17 }
18}問題のある行をクリックしてください。
あなたの判断
1日1回まで。回答するとすぐに正解が表示されます。
連続記録を守る
アカウントを作成すると連続記録を保存し、進捗を追跡できます。