
WebSockets
Socket.io, gateways, events, rooms, namespaces, authentication, broadcasting
1What is a WebSocket Gateway in NestJS?
What is a WebSocket Gateway in NestJS?
คำตอบ
A WebSocket Gateway is a class decorated with @WebSocketGateway() that handles WebSocket connections and real-time events. It acts as an entry point for bidirectional communication between server and clients. Gateways use Socket.io by default and allow handling incoming and outgoing events via decorators like @SubscribeMessage().
2Which library does NestJS use by default for WebSockets?
Which library does NestJS use by default for WebSockets?
คำตอบ
NestJS uses Socket.io by default for WebSockets. Socket.io provides advanced features like rooms, namespaces, automatic reconnection and long-polling fallback. It's possible to use ws (native WebSocket) by specifying the adapter, but Socket.io remains the recommended choice for most use cases.
3How to listen to a WebSocket event in a NestJS Gateway?
How to listen to a WebSocket event in a NestJS Gateway?
คำตอบ
To listen to an event, use the @SubscribeMessage('eventName') decorator on a Gateway method. The method automatically receives data emitted by the client. The decorator handles event registration and allows returning a response to the client or broadcasting to multiple clients.
Which lifecycle method allows executing code when a client connects to the Gateway?
What is a Room in Socket.io?
+17 คำถามสัมภาษณ์
หัวข้อสัมภาษณ์ Node.js / NestJS อื่นๆ
Node.js Fundamentals
Node.js Core APIs
Asynchronous Programming
Express.js Basics
NestJS Fundamentals
REST API Design
Validation & DTO
API Documentation & Contracts
Error Handling
Unit Testing
Task Scheduling
NestJS Modules & DI
Configuration & Environment Management
JWT Authentication
Authorization & RBAC
Database with TypeORM
Prisma ORM
Middleware & Interceptors
File Upload
GraphQL with NestJS
End-to-End Testing
Caching with Redis
Queues with Bull
DevOps, Logging & CI/CD
Docker & Containerization
Microservices
Security Best Practices
Performance & Cloud Deployment
เชี่ยวชาญ Node.js / NestJS สำหรับการสัมภาษณ์ครั้งถัดไป
เข้าถึงคำถามทั้งหมด flashcards แบบทดสอบเทคนิค แบบฝึกหัด code review และตัวจำลองสัมภาษณ์
เริ่มใช้ฟรี