Pipes — WebSockets · NestJS

Validate what a socket sends: the ValidationPipe on a gateway, refusals turned into WsException so the client learns what was wrong, and a parameter pipe whose ordinary BadRequestException would reach the client only as Internal server error.

What you will learn

Read the theory for Pipes

All WebSockets lessons

All NestJS courses

loading types…

What you'll learn

  • Validate message payloads with a ValidationPipe bound to a gateway with @UsePipes()
  • Explain why a pipe's BadRequestException reaches a socket as Internal server error, and fix it with an exceptionFactory returning a WsException
  • Bind a pipe to one parameter, @MessageBody('id', pipe), and give it its own exceptionFactory