1.0.5 • Published 3 years ago

@dollarsign/nestjs-exceptions v1.0.5

Weekly downloads
42
License
MIT
Repository
github
Last release
3 years ago

NestJS Exceptions

Installation

Yarn

yarn add @dollarsign/nestjs-exceptions

NPM

npm install --save @dollarsign/nestjs-exceptions

Usage

To create a global-scoped filter, you would do the following:

// main.ts
async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.useGlobalFilters(new GlobalExceptionFilter());
  await app.listen(3000);
}
bootstrap();

To instantiate a microservice

// main.ts
async function bootstrap() {
  const app = await NestFactory.create(AppModule);
    AppModule,
    {
      transport: Transport.TCP,
    },
  );
  app.useGlobalFilters(new GlobalRpcExceptionFilter());
}
bootstrap();

The following example uses a manually instantiated method-scoped filter. Just as with HTTP based applications, you can also use controller-scoped filters (i.e., prefix the controller class with a @UseFilters() decorator).

@UseFilters(new GlobalRpcExceptionFilter())
@MessagePattern({ cmd: 'sum' })
accumulate(data: number[]): number {
  return (data || []).reduce((a, b) => a + b);
}

Contributing

Contributions welcome! See Contributing.

Author

Dollarsign

License

Licensed under the MIT License - see the LICENSE file for details.

1.0.5

3 years ago

1.0.3

3 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.0

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago