hubhook

github post-receive service hook handler

hubhook

A github post-commit service hook handler

example.js

var hook = require('hubhook')();
 
var http = require('http');
 
http.createServer(function (reqres) {
  if (req.method === 'POST' && req.url === '/api/webhooks/git') {
    return hook.handle(req, res);
  }
  res.statusCode = 404;
  res.setHeader('content-type': 'application/json');
  res.end(JSON.stringify({
    error: 404,
    message: 'not_found',
    hints: 'POST to /api/webhooks/git'
  }, true, 2));
}).listen(7005);
 
hook.on('payload', function (payload) {
  console.log(payload);
});

(example with a random repo of mine)

$ node example.js
{ pusher: { name: 'none' },
  repository: 
   { name: 'my-little-proxy',
     size: 168,
     has_wiki: true,
     created_at: '2012-09-16T12:08:06-07:00',
     private: false,
     watchers: 6,
     url: 'https://github.com/jesusabdullah/my-little-proxy',
     fork: false,
     language: 'JavaScript',
     pushed_at: '2012-09-23T02:04:52-07:00',
     id: 5832190,
 
***snip***

A constructor. Can call without new like so: var hook = HubHook().

Handle the request as a webhook post.

This event is emitted after hook.handle processes a hook payload.

$ npm test

MIT/X11