Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

lit-fastify-bugsnag

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lit-fastify-bugsnag

Fastify plugin for Bugsnag

latest
Source
npmnpm
Version
0.3.1
Version published
Maintainers
1
Created
Source

Fastify Bugsnag Plugin

Easily send your application errors to Bugsnag from your Fastify server.

Installation

npm install fastify-bugsnag --save

# OR

yarn add fastify-bugsnag

Usage

const fastify = require('fastify')();

fastify.register(require('fastify-bugsnag'), {
  key: 'Your-Bugsnag-API-Key', // Defaults to process.env.BUGSNAG_API_KEY
  enableReporting: process.env.NODE_ENV === 'production', // OR similar
  bugsnagOptions: {
    appType: 'web',
  }
});

fastify.get('/', async (request, reply) => {
  fastify.bugsnag.leaveBreadcrumb('Visited homepage'); // OR request.bugsnag.leaveBreadcrumb();
});

fastify.get('/error', async (request, reply) => {
  request.bugsnag.notify(new Error('This is a generic error'));
});

Description

The plugin will decorate fastify instance with bugsnag property and request as well. The value behind bugsnag, is a full BugsnagClient. Bugsnag documentation

Be aware that the plugin mimics the behaviour of official Bugsnag Express plugin with appending the request data to the error. That includes body, query and params which may include user data!

Options

ParameterDefault ValueDescription
keyprocess.env.BUGSNAG_API_KEYAPI Key obtained from Bugsnag dashboard project. REQUIRED
enableReportingundefinedSet to true on environments or under conditions you want to report the errors to Bugsnag.
bugsnagOptions{}Additional configuration options for Bugsnag Client.

License

Licensed under MIT.

Keywords

fastify

FAQs

Package last updated on 29 Nov 2021

Did you know?

Socket

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.

Install

Related posts