Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/joshgillies/tito-webhook

A Node.js middleware for Tito webhook requests
https://github.com/joshgillies/tito-webhook

Last synced: 5 days ago
JSON representation

A Node.js middleware for Tito webhook requests

Awesome Lists containing this project

README

        

# tito-webhook

A Node.js middleware for Tito webhook requests.

[![Build Status](https://travis-ci.org/joshgillies/tito-webhook.svg)](https://travis-ci.org/joshgillies/tito-webhook)

## 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')`:

```js
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:

```js
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:

```js
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