haravan-validate

1.0.2 • Public • Published

haravan-validate

Simple express middleware to validate haravan web hooks

Install

$ npm install --save haravan-validate

Usage

var express = require('express')
  , bodyParser = require('body-parser')
  , Haravan = require('haravan-validate')
  , haravanSecret = process.env.HARAVAN_SECRET
 
var haravan = new Haravan(haravanSecret)
// make sure the haravan validate middleware
// is added before bodyParser
var middleware = [haravan, bodyParser.json()]
 
var app = express()
 
app.post('/webhook', middleware, function(req, res) {
  // validate the request is from haravan
  if (!req.fromHaravan()) {
    return res.status(401).send()
  }
 
  // send success notification to haravan
  // done before to prevent timeout
  res.status(200).send()
 
  var body = req.body
  // process webhook
})

Test

$ npm test

Author

Haravan Team

Install

npm i haravan-validate

DownloadsWeekly Downloads

1

Version

1.0.2

License

MIT

Last publish

Collaborators

  • lmcuong29