Skip to content

@WsDoc

Decorator that marks a gateway method as a documented WebSocket event.

Usage

typescript
import { WsDoc } from '@wsgate/nest';

@WsDoc({
  event: 'message:send',
  description: 'Send a message to a room.',
  payload: { room: 'string', text: 'string' },
  response: 'message:receive',
  type: 'emit',
})
@SubscribeMessage('message:send')
handleSendMessage(@MessageBody() data: any) {}

Options

OptionTypeRequiredDescription
eventstringSocket.IO event name
type'emit' | 'subscribe'Direction of the event
descriptionstringShown in the UI
payloadRecord<string, string>Field names → type labels
responsestringResponse event name (emit only)

Event Types

  • emit — client sends this event to the server
  • subscribe — server sends this event to the client (stub method, no @SubscribeMessage needed)

Released under the MIT License.