https://github.com/friedrith/webhook-catcher
Express router to catch webhooks
https://github.com/friedrith/webhook-catcher
Last synced: 12 days ago
JSON representation
Express router to catch webhooks
- Host: GitHub
- URL: https://github.com/friedrith/webhook-catcher
- Owner: friedrith
- License: mit
- Created: 2017-04-05T08:41:20.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-17T17:25:18.000Z (over 8 years ago)
- Last Synced: 2025-02-07T06:12:43.490Z (over 1 year ago)
- Language: JavaScript
- Size: 57.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# webhook-catcher
This is an express router to catch webhooks. So you add this router to your express server and this router will emit signal when webhooks are triggered by services.
## Install
```bash
$ npm install webhook-catcher
```
## Getting started
```javascript
import WebhookCatcher from 'webhook-catcher'
import express from 'express'
const app = express()
const catcher = new WebhookCatcher({
services: [ 'bitbucket', 'github' ],
token: '...',
})
app
.use('/webhook', catcher.router)
.get('/', (req, res) => {
res.send('ok')
})
catcher.on('push', (pullRequest) => {
// pull request
// {
// appName: ...,
// repositoy: ...,
// service: 'github' | 'bitbucket',
// branchSource: ...,
// branchDestination: ...,
// description: ...,
// title: ...,
// reviewers: ...,
// url: ...,
// see all fields in the following documentation
// }
})
catcher.on('push', (push) => {
// push
// {
// appName: ...,
// repositoy: ...,
// service: 'github' | 'bitbucket',
// branch: '...', // which branch is concerned
// }
})
```
## Available services
For now, it manages services:
* github
* bitbucket
See how to define webhook in services in [services documentation](doc/services.md)
If you want specific tokens for each service, you can also define the webhook catcher like this:
```js
const catcher = new WebhookCatcher({
services: [
{
name: 'bitbucket',
token: '...',
},
{
name: 'github',
token: '...',
}],
})
```
## Available events
For now, it manages events:
* push
* pull request
See all events fields in [events documentation](doc/events.md)
## Links
* [Bitbucket api](https://confluence.atlassian.com/bitbucket/event-payloads-740262817.html#EventPayloads-Repositoryevents)
* [Github api](https://developer.github.com/webhooks/)