Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 1.1 KB

README.md

File metadata and controls

51 lines (38 loc) · 1.1 KB

Build status Dependencies

Install

npm install --save error.flynn

Use

First, setup an Incoming Webhook in Slack https://<your team>.slack.com/services/

Then:

const express = require('express')
  , flynn = require('error.flynn')
  , app = express()
  ;

app.get('/', (req, res, next) => {
  next(new Error('Send me to Slack!'));
});
// Either set process.env.ERROR_FLYNN_URL or use the url as the first param for flynn)
app.use(flynn('https://hooks.slack.com/services/TOKEN'));
app.use((err, req, res, next) => {
  res.sendStatus(500);
});

The last part (below the comment) could also be done more concisely:

app.use(flynn('https://hooks.slack.com/services/TOKEN'), (err, req, res, next) => {
  res.sendStatus(500);
});

Tests

npm test

Example Output

Slack message