npm install node-webhooks --save
// Initialize WebHooks.
var WebHooks =
// Initialize webhooks from database
var webHooks =
db: './webHooksDB.json' // json file that store webhook URLs
httpSuccessCodes: 200 201 202 203 204
// Alternatively, initialize webhooks with object
webHooks =
db: "addPost": "http://localhost:9100/posts"
// sync instantation - add a new webhook called 'name1'
webHooks
// add another webHook
webHooks
;
// remove a single url attached to the given shortname
// webHooks.remove('name3', 'http://127.0.0.1:9000/query/').catch(function(err){console.error(err);})
// if no url is provided, remove all the urls attached to the given name
// webHooks.remove('name3').catch(function(err){console.error(err);})
// trigger a specific webHook
webHooks
webHooks // payload will be sent as POST request with JSON body (Content-Type: application/json) and custom header