|
1 | 1 | import {
|
2 | 2 | CallHandler,
|
3 | 3 | ExecutionContext,
|
4 |
| - HttpStatus, |
5 | 4 | Injectable,
|
6 | 5 | NestInterceptor,
|
7 | 6 | } from "@nestjs/common";
|
8 | 7 | import { Observable, throwError } from "rxjs";
|
9 | 8 | import { catchError } from "rxjs/operators";
|
10 |
| -import { |
11 |
| - GrpcAbortedException, |
12 |
| - GrpcAlreadyExistsException, |
13 |
| - GrpcInternalException, |
14 |
| - GrpcInvalidArgumentException, |
15 |
| - GrpcNotFoundException, |
16 |
| - GrpcPermissionDeniedException, |
17 |
| - GrpcResourceExhaustedException, |
18 |
| - GrpcUnauthenticatedException, |
19 |
| - GrpcUnknownException, |
20 |
| -} from "../exceptions"; |
21 |
| - |
22 |
| -const GRPC_EXCEPTION_FROM_HTTP: Record<number, any> = { |
23 |
| - [HttpStatus.NOT_FOUND]: GrpcNotFoundException, |
24 |
| - [HttpStatus.FORBIDDEN]: GrpcPermissionDeniedException, |
25 |
| - [HttpStatus.METHOD_NOT_ALLOWED]: GrpcAbortedException, |
26 |
| - [HttpStatus.INTERNAL_SERVER_ERROR]: GrpcInternalException, |
27 |
| - [HttpStatus.TOO_MANY_REQUESTS]: GrpcResourceExhaustedException, |
28 |
| - [HttpStatus.BAD_GATEWAY]: GrpcUnknownException, |
29 |
| - [HttpStatus.CONFLICT]: GrpcAlreadyExistsException, |
30 |
| - [HttpStatus.UNPROCESSABLE_ENTITY]: GrpcInvalidArgumentException, |
31 |
| - [HttpStatus.UNAUTHORIZED]: GrpcUnauthenticatedException, |
32 |
| -}; |
| 9 | +import { GRPC_EXCEPTION_FROM_HTTP } from "../utils"; |
33 | 10 |
|
34 | 11 | @Injectable()
|
35 | 12 | export class HttpToGrpcInterceptor implements NestInterceptor {
|
|
0 commit comments