express-errors-to-slack

Sends all your express errors/exceptions to Slack channel via Slack webhooks (which may be rate limited by slack server) or via Slack API

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
express-errors-to-slack
101.0.35 years ago5 years agoMinified + gzip package size for express-errors-to-slack in KB

Readme

express-errors-to-slack
NodeJS ExpressJS middleware that Sends all your express errors/exceptions to Slack channel via Slack webhooks (which may be rate limited by slack server) or via Slack API

Installation

`` npm install express-errors-to-slack ``

Example usage with Slack API

Replace APITOKEN> with API Token obtained from https://api.slack.com/tokens ```javascript 'use strict'; const express = require('express'); const slackErrors = require('./index.js'); 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(slackErrors({ token: 'APITOKEN>', channel: '#logsnodejs' })); app.listen(3000); ```

Example usage with Slack Webhook

Replace WEBHOOKURL> with your incoming webhook url obtained from https://api.slack.com/slack-apps But remember slack servers limit rate if your logs exceed 1 message per second. API usage preffered ```javascript 'use strict'; const express = require('express'); const slackErrors = require('./index.js'); 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(slackErrors({ webhookUri: 'WEBHOOKURL>', channel: '#logsnodejs' })); app.listen(3000); ```