send-error-slack
v1.0.5
Published
The library helps the system to send errors to slack
Downloads
4
Maintainers
Readme
The library helps the system to send errors to slack
Install
$ npm install --save send-error-slack
Usage express without route
const express = require('express')
const sendErrorSlack = require('send-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(sendErrorSlack({ webhookUri: 'https://hooks.slack.com/services/TOKEN' }))
app.listen(3000)
Usage express route
/*
File index.js
*/
var express = require('express'),
app = express(),
bodyParser = require('body-parser');
app.use(bodyParser.json()); // support json encoded bodies
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies
require('./route')(app); //importing route
/*
File Route.js
*/
const sendErrorSlack = require('send-error-slack')
const webhookUri = 'https://hooks.slack.com/services/TOKEN';
module.exports = function(app) {
app.route('/api/checkError').get([TEST_CONTROLLER.checkError])
// ERRORS
app.use(sendErrorSlack({webhookUri}))
}
API
const sendErrorSlack = require('send-error-slack')