express-error-slack

2.0.0 • Public • Published

express-error-slack

NPM version Build Status Coverage Status

Express error handling middleware for reporting error to Slack

Install

$ npm install --save express-error-slack

Usage

const express = require('express')
const errorToSlack = require('express-error-slack')
 
const app = express()
 
// Route that triggers a error
app.get('/error', function (req, res, next) {
  const err = new Error('Internal Server Error')
  err.status = 500
  next(err)
})
 
// Send error reporting to Slack
app.use(errorToSlack({ webhookUri: 'https://hooks.slack.com/services/TOKEN' }))
app.listen(3000)

API

const errorToSlack = require('express-error-slack')

errorToSlack(options)

Create a error handling middleware to send error reporting to Slack channel.

Options

{
  webhookUri: String,
  skip: function (err, req, res) { return false },
  debug: Boolean
}
  • webhookUri: Required. Your Slack webhook uri that the channel will receive error reporting.
  • skip: Optional. A function to determine if handler is skipped. Defaults to always returning false.
  • debug: Optional. Show logging of response from Slack if set true. Defaults to false.

Result Example

4xx

Slack Message

5xx

Slack Message

License

MIT © Chun-Kai Wang

Package Sidebar

Install

npm i express-error-slack

Weekly Downloads

101

Version

2.0.0

License

MIT

Unpacked Size

6.94 kB

Total Files

5

Last publish

Collaborators

  • chunkai1312