npm.io
0.1.0 • Published 10 years ago

error.flynn

Licence
ISC
Version
0.1.0
Deps
2
Vulns
0
Weekly
0

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