Files
main.tsmain
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
Press Run tests to start the app. Its log appears here.Graded endpoints
Everything in this lesson happens between Ada and the gateway
The ValidationPipe refuses the payload; the exceptionFactory's WsException carries every message, sent as the exception event
A missing property fails both of its rules
A payload that passes reaches the handler, which acknowledges the stored cat
ParseIntPipe refuses it; with its exceptionFactory the client reads ParseIntPipe's own message instead of Internal server error
A numeric string passes, and the handler gets the number
A valid id for a cat the shelter does not have is the handler's business, not the pipe's
run the tests first
Frames
Run the tests first.