micro-rollbar
v1.0.4
Published
Rollbar error handler for Zeit's Micro
Downloads
12
Readme
micro-rollbar
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
- Fork this repository to your own GitHub account and then clone it to your local device
- Install the dependencies:
yarn
- Link the package to the global module directory:
yarn link
- Run
yarn test -- --watch
and start making your changes - You can use
yarn link micro-rollbar
to test your changes in an actual project
LICENSE
MIT