Interceptors

There is no difference between regular interceptors and the web sockets interceptors. Here is an example that makes use of a manually instantiated method-scoped filter (class-scoped works either):

TypeScript

@UseInterceptors(new TransformInterceptor())
@SubscribeMessage('events')
onEvent(client, data: any): WsResponse<any> {
  const event = 'events';
  return { event, data };
}
  • Interceptors

Support us

Nest is an MIT-licensed open source project. It can grow thanks to the support by these awesome people. If you'd like to join them, please read more here.

Principal Sponsor

Sponsors / Backers