Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nestjs-grpc-exceptions

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestjs-grpc-exceptions - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

lib/filters/grpc-http-exception.filter.ts

6

CHANGELOG.md
# nestjs-grpc-exceptions
## 0.1.0
### Minor Changes
- 5b7dbb2: add grpc to http interceptor
## 0.0.1

@@ -4,0 +10,0 @@

12

dist/index.d.ts

@@ -1,2 +0,2 @@

import { RpcExceptionFilter } from '@nestjs/common';
import { RpcExceptionFilter, ExceptionFilter, ArgumentsHost, NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
import { RpcException } from '@nestjs/microservices';

@@ -9,2 +9,6 @@ import { Observable } from 'rxjs';

declare class GrpcHttpExceptionFilter implements ExceptionFilter {
catch(exception: any, host: ArgumentsHost): void;
}
declare class GrpcNotFoundException extends RpcException {

@@ -54,2 +58,6 @@ constructor(error: string | object);

export { GrpcAbortedException, GrpcAlreadyExistsException, GrpcCancelledException, GrpcInternalException, GrpcInvalidArgumentException, GrpcNotFoundException, GrpcPermissionDeniedException, GrpcResourceExhaustedException, GrpcServerExceptionFilter, GrpcUnauthenticatedException, GrpcUnavailableException, GrpcUnknownException };
declare class GrpcToHttpInterceptor implements NestInterceptor {
intercept(_context: ExecutionContext, next: CallHandler<any>): Observable<any> | Promise<Observable<any>>;
}
export { GrpcAbortedException, GrpcAlreadyExistsException, GrpcCancelledException, GrpcHttpExceptionFilter, GrpcInternalException, GrpcInvalidArgumentException, GrpcNotFoundException, GrpcPermissionDeniedException, GrpcResourceExhaustedException, GrpcServerExceptionFilter, GrpcToHttpInterceptor, GrpcUnauthenticatedException, GrpcUnavailableException, GrpcUnknownException };
export * from "./grpc-server-exception.filter";
export * from "./grpc-http-exception.filter";
export * from "./filters";
export * from "./exceptions";
export * from "./interceptors";
import type { status as GrpcStatusCode } from "@grpc/grpc-js";
import { RpcException } from "@nestjs/microservices";

@@ -22,2 +23,3 @@ export type GrpcExceptionPayload = {

type: typeof error === "string" ? "string" : "object",
exceptionName: RpcException.name,
}),

@@ -24,0 +26,0 @@ code,

export * from "./error-object";
export * from "./http-codes-map";

20

package.json

@@ -6,10 +6,14 @@ {

"author": "Mohsen Bostan <mohsenbostandev@gmail.com",
"version": "0.0.1",
"homepage": "https://github.com/mohsenbostan/nestjs-grpc-exceptions",
"bugs": {
"url": "https://github.com/mohsenbostan/nestjs-grpc-exceptions/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/mohsenbostan/nestjs-grpc-exceptions.git"
},
"version": "0.1.0",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsup index.ts --format cjs,esm --dts",
"lint": "tsc"
},
"devDependencies": {

@@ -31,3 +35,7 @@ "@changesets/cli": "^2.26.0",

"@nestjs/microservices": "^8.0.0 || ^9.0.0"
},
"scripts": {
"build": "tsup index.ts --format cjs,esm --dts",
"lint": "tsc"
}
}
}

@@ -43,5 +43,20 @@ # NestJS gRPC Exceptions

Now you can use the exception classes:
Add the client interceptor to your client:
```ts
import { GrpcToHttpInterceptor } from 'nestjs-grpc-exceptions';
@Get(':id')
@UseInterceptors(GrpcToHttpInterceptor)
function findUser(@Param('id') id: number): void;
```
Now you can use the exception classes in your servers:
```ts
import {
GrpcNotFoundException,
GrpcInvalidArgumentException,
} from "nestjs-grpc-exceptions";
throw new GrpcNotFoundException("User Not Found.");

@@ -48,0 +63,0 @@ throw new GrpcInvalidArgumentException("input 'name' is not valid.");

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc