Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spacelan/coding-webhook-handler
Node.js web handler / middleware for processing Coding Webhooks
https://github.com/spacelan/coding-webhook-handler
Last synced: about 1 month ago
JSON representation
Node.js web handler / middleware for processing Coding Webhooks
- Host: GitHub
- URL: https://github.com/spacelan/coding-webhook-handler
- Owner: spacelan
- License: mit
- Created: 2015-08-21T01:07:16.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-22T03:06:41.000Z (about 9 years ago)
- Last Synced: 2024-08-09T15:19:58.839Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 191 KB
- Stars: 18
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# coding-webhook-handler
[![Build Status](https://travis-ci.org/spacelan/coding-webhook-handler.svg)](https://travis-ci.org/spacelan/coding-webhook-handler)
Coding allows you to register **[Webhooks](https://coding.net/help/about_us?key=webhook)** for your repositories. Each time an event occurs on your repository, whether it be pushing code, filling issues or creating pull requests, the webhook address you register can be configured to be pinged with details.
This library is a fork of [github-webhook-handler](https://github.com/rvagg/github-webhook-handler). It is a small handler (or "middleware" if you must) for Node.js web servers that handles all the logic of receiving and verifying webhook requests from Coding.
## Install
`npm install coding-webhook-handler`
## Example
```js
var http = require('http')
var createHandler = require('coding-webhook-handler')
var handler = createHandler({
path: '/webhook',
token: 'mytoken' // maybe there is no token
})http.createServer(function(req, res) {
handler(req, res, function(err) {
res.statusCode = 404
res.end('no such location')
})
}).listen(7777)handler.on('error', function(err) {
console.error('Error:', err.message)
})handler.on('*', function(event) {
console.log(event.event)
console.log(event.payload)
console.log(event.protocol)
console.log(event.host)
console.log(event.url)
})handler.on('push', function(event) {
console.log(event)
})handler.on('star', function(event) {
console.log(event)
})
```## License
MIT