Koa.js middleware for processing GitHub Webhooks
This library is a small middleware for Koa.js web servers that handles all the logic of receiving and verifying webhook requests from GitHub. It's based on the awesome job of @rvagg here.
Any JSON body parser middleware for Koa.js (see complete list here).
;;;const app = ;const githubWebhookHandler =path: '/webhook'secret: 'myhashsecret';githubWebhookHandler;app;app;app;
koa-github-webhook-handler exports a class, you must instantiate it with an options object. Your options object should contain:
"path": the complete case sensitive path/route to match when looking at
req.urlfor incoming requests. Any request not matching this path will
yieldto the "downstream" middleware.
"secret": this is a hash key used for creating the SHA-1 HMAC signature of the JSON blob sent by GitHub. You should register the same secret key with GitHub. Any request not delivering a
X-Hub-Signaturethat matches the signature generated using this key against the blob will throw an HTTP
The middleware method return a
GeneratorFunction wich act like a common middleware that you can insert into a processing chain. The next middleware is not
yield if the request is successfully handled.
The class inherits form
EventEmitter, so you can register handler to listen to any of the GitHub event types. Note you can be specific in your GitHub configuration about which events you wish to receive, or you can send them all.
See the GitHub Webhooks documentation for more details on the events you can receive.
Additionally, there is a special
'*' event you can listen to in order to receive everything.
koa-github-webhook-handler is Copyright (c) 2015 TinOo512 @TinOo512 and licensed under the MIT License. All rights not explicitly granted in the MIT License are reserved. See the included LICENSE.md file for more details.