micro-rollbar

1.0.4 • Public • Published

micro-rollbar

Build Status Greenkeeper badge XO code style styled with prettier

Rollbar error handler for Zeit's Micro

Installation

npm install --save micro-rollbar

Usage

Using the global error handler:

const {createError} = require('micro')
const microRollbar = require('micro-rollbar')
 
const errorHandler = microRollbar({
  accessToken: 'ROLLBAR_ACCESS_TOKEN'
})
 
module.exports = errorHandler(async (req, res) => {
  throw createError(500, 'Reported to rollbar')
})

Using the global error handler with additional options:

const {send} = require('micro')
const microRollbar = require('micro-rollbar')
const {debug, info, warning, error, critical} = microRollbar
 
// See Rollbar documentation for available options.
// https://rollbar.com/docs/notifier/rollbar.js/#standalone
const errorHandler = microRollbar({
  accessToken: 'ROLLBAR_ACCESS_TOKEN',
  environment: process.env.NODE_ENV || 'development',
  host: 'app.domain.com',
  enabled: process.env.NODE_ENV !== 'test'
})
 
module.exports = errorHandler(async (req, res) => {
  await info('Reported to rollbar')
  send(res, 200, 'Ready!')
})

Contributors

Thanks goes to these wonderful people (emoji key):


Brent Mealhouse

💻 📖 ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

Contributing

  1. Fork this repository to your own GitHub account and then clone it to your local device
  2. Install the dependencies: yarn
  3. Link the package to the global module directory: yarn link
  4. Run yarn test -- --watch and start making your changes
  5. You can use yarn link micro-rollbar to test your changes in an actual project

LICENSE

MIT

Readme

Keywords

Package Sidebar

Install

npm i micro-rollbar

Weekly Downloads

4

Version

1.0.4

License

MIT

Last publish

Collaborators

  • bmealhouse