
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
@ssut/nest-bugsnag
Advanced tools
A Nest module wrapper for bugsnag logger.
A Nest module wrapper for bugsnag-js logger.
$ npm i @bugsnag/plugin-express --save
$ npm i @nkaurelien/nest-bugsnag --save
Import the BugsnagModule
into the module. For example AppModule
:
import { Module } from '@nestjs/common';
import { BugsnagModule } from '@nkaurelien/nest-bugsnag';
import BugsnagPluginExpress from '@bugsnag/plugin-express'
@Module({
imports: [
BugsnagModule.forRoot({
apiKey: '<API_KEY>',
plugins: [BugsnagPluginExpress],
}),
],
})
export class AppModule { }
In the main.ts file, change the HTTP platform to use express
// change
const app = await NestFactory.create(AppModule);
// to
const app = await NestFactory.create<NestExpressApplication>(AppModule);
This handles any errors that Express catches
app.get(BugsnagService).handleAnyErrors(app);
Then you can inject BugsnagService. Example:
import { Controller } from '@nestjs/common';
import { BugsnagService } from '@nkaurelien/nest-bugsnag';
@Controller('cats')
export class CatsController {
constructor(private readonly logger: BugsnagService) { }
}
BugsnagService has instance property which wrap bugsnag client. So you can access it by calling:
try {
something.risky()
} catch (e) {
this.logger.instance.notify('message');
}
In your controller, you can call req.bugsnag.notify(err) which will include information about the request in the error report. For example:
@Get()
getHello(@Request() req): string {
req.bugsnag.notify(
new Error('First Error'),
function (event) {
// event.addMetadata('product', product)
});
return 'Hello World!';
}
Note that BugsnagModule
is a global module, it will be available in all you feature modules.
import { Module } from '@nestjs/common';
import { BugsnagModule } from '@nkaurelien/nest-bugsnag';
@Module({
imports: [
BugsnagModule.forRootAsync({
useFactory: (configService: ConfigService) => ({
// options
}),
inject: [ConfigService],
}),
],
})
export class AppModule { }
The factory might be async and is able to inject dependencies through the inject
option.
bugsnagJs, nestJs, logger
FAQs
A Nest module wrapper for bugsnag
We found that @ssut/nest-bugsnag demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.