Guards
There is no difference between microservices guards and the regular guards. The only thing you should be aware of is that instead of throwing HttpException, you should use the RpcException.
Hint TheRpcExceptionclass is exposed from@nestjs/microservicespackage.
Binding guards
Here is an example that makes use of a method-scoped guard (class-scoped works either):
TypeScript
@UseGuards(AuthGuard)
@MessagePattern({ cmd: 'sum' })
sum(data: number[]): number {
return (data || []).reduce((a, b) => a + b);
}