Giter Club home page Giter Club logo

paperplane-bugsnag's Introduction

paperplane-bugsnag

A bugsnag wrapper for paperplane.

npm version npm downloads Build Status Coverage Status

Filters `Boom` client errors (4xx) and `Joi` validation errors by default, and adds request data to the error notification for debugging.

Usage

Setup your bugsnag like this:

// server/lib/bugsnag.js

const bugsnag = require('bugsnag')

const bugsnagClient = bugsnag({
  apiKey: process.env.BUGSNAG_API_KEY,
  notifyReleaseStages: ['prod', 'stage'],
  releaseStage: process.env.SERVICE_ENV
})

const optionalCustomLogger =
  err => console.error(`My custom logged error: ${err.message}`)

module.exports = require('paperplane-bugsnag')(bugsnagClient, optionalCustomLogger)

Then use it as the cry option in paperplane like this:

// server/index.js

const http = require('http')
const { mount } = require('paperplane')

const app = require('./rest')
const cry = require('./lib/bugsnag').notify

http.createServer(mount({ app, cry })).listen(3000, cry)

By default, Boom client errors (4xx) and Joi validitation errors will be ignored.

// server/rest.js
module.exports = req => {
  const err = Boom.badRequest()
  return Promise.reject(err) // does not send notification
}

We can force a notification by setting cry=true on the error.

// server/rest.js
module.exports = req => {
  const err = Boom.badRequest()
  err.cry = true
  return Promise.reject(err) // sends notification
}

paperplane-bugsnag's People

Contributors

flintinatux avatar jwa111 avatar mgreystone avatar pklingem avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.