Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dcampagnola/nestjs-bugsnag
https://github.com/dcampagnola/nestjs-bugsnag
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dcampagnola/nestjs-bugsnag
- Owner: DCampagnola
- Created: 2022-02-01T17:33:11.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-02-27T21:29:58.000Z (almost 2 years ago)
- Last Synced: 2024-10-18T15:53:09.424Z (3 months ago)
- Language: TypeScript
- Size: 990 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest
A progressive Node.js framework for building efficient and scalable server-side applications.
## Description
[Bugsnag](https://github.com/bugsnag/bugsnag-js) module for [Nest](https://github.com/nestjs/nest)
## Installation
```bash
$ npm install --save nestjs-bugsnag @bugsnag/js
```## Usage
In the root of your project:
```typescript
import { BugsnagModule } from 'nestjs-bugsnag';
import BugsnagPluginExpress from '@bugsnag/plugin-express'@Module({
imports: [
BugsnagModule.forRoot({
apiKey: '',
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:
```typescript
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](https://docs.bugsnag.com/platforms/javascript/configuration-options/)
You can inject the `BugsnagService` to use it in your application:
```typescript
import { BugsnagService } from 'nestjs-bugsnag';@Controller()
export class AppController {
constructor(private readonly bugsnagService: BugsnagService) {
}failingMethod() {
this.bugsnagService.notify(new Error('Something went wrong'));
}
}
```