mohsenbostan / nestjs-grpc-exceptions

NestJS gRPC Exceptions Library ⚡️
MIT License
31 stars 11 forks source link

refactor: Generalize HttpToGrpcInterceptor with status code map. #11

Closed youngkiu closed 3 months ago

youngkiu commented 3 months ago

First, I am well using the nestjs-grpc-exceptions package. thank you

  1. Even if it is not defined in the HTTP_CODE_FROM_GRPC map, GrpcToHttpInterceptor always throws HttpException(). Even if the exception is not defined in the GRPC_CODE_FROM_HTTP map, HttpToGrpcInterceptor has always been modified to throw RpcException ().

  2. Instead of defining the GRPC_EXCEPTION_FROM_HTTP exception map, I defined the GRPC_CODE_FROM_HTTP code map as HTTP_CODE_FROM_GRPC.

  3. I added test/interceptors/http-to-grpc-interceptor.spec.ts test code for HttpToGrpcInterceptor.