@schramautoparts/nest-bugsnag
TypeScript icon, indicating that this package has built-in type declarations

10.0.0 • Public • Published

Nest Logo

A Nest module wrapper for bugsnag logger.

NPM Version Package License

Description

A Nest module wrapper for bugsnag-js logger.

Installation

$ npm i @schramautoparts/nest-bugsnag --save

Quick Start

Import the BugsnagModule into the module. For example AppModule:

import { Module } from '@nestjs/common';
import { BugsnagModule } from '@schramautoparts/nest-bugsnag';

@Module({
  imports: [
    // or registerAsync()
    BugsnagModule.register({
      apiKey: '<API_KEY>',
    }),
  ], 
  // Global Http Exception Filter
  providers: [{
    provide: APP_FILTER,
    useClass: BugsnagExceptionsFilter,
  }],
})
export class AppModule { }

Then you can inject BugsnagService. Example:

import { Controller } from '@nestjs/common';
import { BugsnagService } from '@schramautoparts/nest-bugsnag';

@Controller('cats')
export class CatsController {
  constructor(private readonly bugsnag: BugsnagService) { }
}

BugsnagService has instance property which wrap bugsnag client. So you can access it by calling:

try {
  something.risky()
} catch (e) {
    this.bugsnag.instance.notify('message');
}

Async configuration Sample

import { Module } from '@nestjs/common';
import { BugsnagModule } from '@schramautoparts/nest-bugsnag';

@Module({
  imports: [
    BugsnagModule.registerAsync({
      useFactory: (configService: ConfigService) => ({
        // options
      }),
      inject: [ConfigService],
    }),
  ],
})
export class AppModule { }

The factory might be async and is able to inject dependencies through the inject option.

Readme

Keywords

Package Sidebar

Install

npm i @schramautoparts/nest-bugsnag

Weekly Downloads

24

Version

10.0.0

License

MIT

Unpacked Size

14 kB

Total Files

12

Last publish

Collaborators

  • jostrander