0% found this document useful (0 votes)
3 views

docs-nestjs-com-websockets-pipes...

The document discusses the similarities between regular pipes and web sockets in NestJS, highlighting the use of WsException instead of HttpException. It also provides an example of using a method-scoped pipe with the @UsePipes() decorator for gateway-scoped pipes. Additionally, it promotes support for the Nest open-source project and encourages newsletter subscriptions for updates.

Uploaded by

dharmendra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

docs-nestjs-com-websockets-pipes...

The document discusses the similarities between regular pipes and web sockets in NestJS, highlighting the use of WsException instead of HttpException. It also provides an example of using a method-scoped pipe with the @UsePipes() decorator for gateway-scoped pipes. Additionally, it promotes support for the Nest open-source project and encourages newsletter subscriptions for updates.

Uploaded by

dharmendra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Search dark_mode

Pipes
There is no fundamental difference between regular pipes and web sockets
pipes. The only difference is that instead of throwing HttpException , you
should use WsException . In addition, all pipes will be only applied to the
Design and
data parameter (because validating or transforming client instance is Development tips in
useless). your inbox. Every
weekday.
ADS VIA CARBON

HINT
The WsException class is exposed from @nestjs/websockets package.

Binding pipes
The following example uses a manually instantiated method-scoped pipe. Just as with HTTP based
applications, you can also use gateway-scoped pipes (i.e., prefix the gateway class with a
@UsePipes() decorator).

JS

@UsePipes(new ValidationPipe({ exceptionFactory: (errors) => new WsException(content_copy


error
@SubscribeMessage('events')
handleEvent(client: Client, data: unknown): WsResponse<unknown> {
const event = 'events';
return { event, data };
}

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 Sponsors

Sponsors / Partners

Become a sponsor

Join our Newsletter


Subscribe to stay up to date with the latest Nest updates, features, and videos!

Email address..

Copyright © 2017-2025 MIT by Kamil Mysliwiec design by Jakub Staron


Official NestJS Consulting Trilon.io hosted by Netlify

You might also like