0.1.8 • Published 2 years ago

nestjs-bugsnag v0.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Description

Bugsnag module for Nest

Installation

$ npm install --save nestjs-bugsnag @bugsnag/js

Usage

In the root of your project:

import { BugsnagModule } from 'nestjs-bugsnag';
import BugsnagPluginExpress from '@bugsnag/plugin-express'

@Module({
  imports: [
    BugsnagModule.forRoot({
      apiKey: '<your-api-key>',
      releaseStage: 'production',
      appVersion: '1.0.0',
      plugins: [BugsnagPluginExpress],
      notifyReleaseStages: ['production'],
      onUncaughtException: true,
      onUnhandledRejection: true,
    }),
  ],
})
export class AppModule {
}

You can add the BugsnagPluginExpress to your plugins array in the forRoot method.

You can also use the forRootAsync method to configure the module:

import { Module } from '@nestjs/common';
import { BugsnagModule } from 'nestjs-bugsnag';
import { ConfigModule } from '@nestjs/config';

@Module({
  imports: [
    ConfigModule.forRoot({
      ...
    }),
    BugsnagModule.forRootAsync({
      inject: [ConfigService],
      imports: [ConfigModule],
      useFactory: (configService: ConfigService) => ({
        apiKey: configService.get('BUGSNAG_API_KEY'),
        releaseStage: configService.get('BUGSNAG_RELEASE_STAGE'),
        appVersion: configService.get('BUGSNAG_APP_VERSION'),
        notifyReleaseStages: configService.get('BUGSNAG_NOTIFY_RELEASE_STAGES'),
        onUncaughtException: configService.get('BUGSNAG_ON_UNCAUGHT_EXCEPTION'),
        onUnhandledRejection: configService.get('BUGSNAG_ON_UNHANDLED_REJECTION'),
      }),
    }),
  ],
})

More options are found in Bugsnag docs

You can inject the BugsnagService to use it in your application:

import { BugsnagService } from 'nestjs-bugsnag';

@Controller()
export class AppController {
  constructor(private readonly bugsnagService: BugsnagService) {
  }

  failingMethod() {
    this.bugsnagService.notify(new Error('Something went wrong'));
  }
}
0.1.8

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago