2.0.2 • Published 1 month ago

haravan-validate v2.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
1 month ago

haravan-validate

Simple express middleware to validate haravan webhooks

Install

$ npm install --save haravan-validate

Usage

const express = require("express");
const HaravanValidate = require("haravan-validate");
const CLIENT_SECRET = process.env.CLIENT_SECRET;

const middlewareValidate = new HaravanValidate(CLIENT_SECRET);
const app = express();

// make sure the haravan validate middleware
// is added before express.json()
app.use(middlewareValidate);
app.use(express.json());

app.post("/webhook", 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();

	const body = req.body;
	// process webhook
});

Test

$ npm test
2.0.2

1 month ago

2.0.1

2 months ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago