node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »

tito-webhook

tito-webhook

A Node.js middleware for Tito webhook requests.

Build Status

API

webhook(path, callback)

Mounts the Tito webhook middleware at path.

callback(err, data)

The callback is called once a webhook request has been recieved.

Example

Vanilla require('http'):

var webhook = require('tito-webhook')
var http = require('http')
 
var _webhook = webhook('/', function done (err, data) {
  if (err) console.log(err)
  conosle.log(JSON.stringify(data))
})
 
var app = http.createServer(function server (req, res) {
  _webhook(req, res, function next () {
    res.statusCode = 404
    res.end()
  })
})
 
app.listen(1337)

Connect:

var webhook = require('tito-webhook')
var connect = require('connect')
 
var app = connect()
 
app.use(webhook('/', function done (err, data) {
  if (err) console.log(err)
  conosle.log(JSON.stringify(data))
})
 
app.listen(1337)

Express:

var webhook = require('tito-webhook')
var express = require('express')
 
var app = express()
 
app.use(webhook('/', function done (err, data) {
  if (err) console.log(err)
  conosle.log(JSON.stringify(data))
})
 
app.listen(1337)

License

MIT