Browse files

add hubhook example

  • Loading branch information...
1 parent c272a6c commit 441aa0ceefa83eff457245bbcc81afac0a96dc81 @jfhbrook committed Sep 24, 2012
Showing with 23 additions and 0 deletions.
  1. +23 −0 examples/hubhook.js
View
23 examples/hubhook.js
@@ -0,0 +1,23 @@
+var hook = require('hubhook')(),
+ pullover = require('../')('/tmp/repos');
+
+var http = require('http');
+
+http.createServer(function (req, res) {
+ 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) {
+ pullover.pull(payload, function (err) {
+ console.log(err || 'success!');
+ });
+});

0 comments on commit 441aa0c

Please sign in to comment.