Using new event emitter library for exposing request information on webHook trigger.
var webHooks = new WebHooks({
db: WEBHOOKS_DB,
DEBUG: true
});
var emitter = webHooks.getEmitter();
emitter.on('*.success', function (shortname, statusCode, body) {
log.info('Success on trigger webHook' + shortname + 'with status code', statusCode, 'and body', body);
});
emitter.on('*.failure', function (shortname, statusCode, body) {
log.error('Error on trigger webHook' + shortname + 'with status code', statusCode, 'and body', body);
});
This makes possible checking if a webHook trigger was succesful or not getting request information such as status code or response body.
The format for the events is builded as eventName.result. The choosen library eventemitter2 provides a lot of freedom for listening events. For example:
Using new event emitter library for exposing request information on webHook trigger.
This makes possible checking if a webHook trigger was succesful or not getting request information such as status code or response body.
The format for the events is builded as
eventName.result
. The choosen libraryeventemitter2
provides a lot of freedom for listening events. For example:eventName.success
eventName.failure
eventName.*
*.success
*.*