Skip to content

Send all your NodeJS ExpressJS errors and exceptions to Slack channel via Slack webhooks (which may be rate limited by slack server) or via Slack API

License

Notifications You must be signed in to change notification settings

xrip/express-slack-errors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 <SLACK_API_TOKEN> with API Token obtained from https://api.slack.com/tokens

'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: '<SLACK_API_TOKEN>', channel: '#logs_nodejs' }));
app.listen(3000);

Example usage with Slack Webhook

Replace <SLACK_WEBHOOK_URL> 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

'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: '<SLACK_WEBHOOK_URL>', channel: '#logs_nodejs' }));
app.listen(3000);

About

Send all your NodeJS ExpressJS errors and exceptions to Slack channel via Slack webhooks (which may be rate limited by slack server) or via Slack API

Topics

Resources

License

Stars

Watchers

Forks

Packages