express-slack-verifier
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

express-slack-verifier

An Express middleware to verify requests from Slack.

Why?

The @slack/events-api does already provide an expressMiddleware() that gives you the signature verification. However, it also hijacks the processing of the event outside of the HTTP request-response loop of Express. This is an issue when deploying a Slackbot in on a serverless platform, where all the work has to be done within that request-response cycle.

This module then provides a simple middleware built on top of slack/events-api that verifies the request signature and, if valid, passes the request processing along the Express middleware stack.

How?

Use the applySlackVerifier function the module exports. It attaches a middleware to a route under which you serve the requests coming from Slack.

import { default as e } from 'express';
import { applySlackVerifier } from 'express-slack-verifier';

const slackSigningSecret = '123456abcdefg';
const slackRouter = e.Router();

applySlackVerifier(router, '/', slackSigningSecret);

router.post('/event', (req, res) => {
    // handle a slack event here
});

Package Sidebar

Install

npm i express-slack-verifier

Weekly Downloads

6

Version

1.0.2

License

MIT

Unpacked Size

4.6 kB

Total Files

5

Last publish

Collaborators

  • milancermak