Socket
Socket
Sign inDemoInstall

@zenginehq/backend-webhooks

Package Overview
Dependencies
0
Maintainers
5
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @zenginehq/backend-webhooks

Helper library for working with Webhooks in Zengine backend plugins.


Version published
Weekly downloads
9
increased by28.57%
Maintainers
5
Install size
1.06 MB
Created
Weekly downloads
 

Changelog

Source

1.2.1 (2018-10-17)

<a name="1.2.0"></a>

Readme

Source

Backend Webhooks

Helper module for working with Webhooks in Zengine backend Plugins.

Coverage Status Build Status npm version

Installation

npm i @zenginehq/backend-webhooks --save

Usage

var $webhook = require('@zenginehq/backend-webhooks');
var $firebase = require('@zenginehq/backend-firebase');
var $api = require('@zenginehq/backend-http');

var workspaceId; // from eventData
var activity; // from eventData

// Load settings from firebase.
$firebase.load(workspaceId).then(function (settings) {
  if (!$webhook.validateSecret(settings, eventData.request)) {
    return eventData.response.status(403).send('Invalid Webhook Key');
  }

  // Load activity.
  return $api.getActivity(activity.id).then(function (fullActivity) {
    if ($webhook.activityToFolder(fullActivity, settings.submittedFolder)) {
      // Do something.
    }
    
    // You can also make sure the activity didn't come from a specific folder.
    if (!$webhook.activityFromFolder(fullActivity, settings.submittedFolder)) {
    	// Do something else.
    	// $api.moveToFolder(approcvedfolder);
    }
  });
});

Methods

validateSecret(settings, request)

Returns whether the webhook id and secret match what's stored in settings.

Out of the box expects the id to be stored in settings.webhookId and the key in settings.webhookKey.

You can customize this by calling $webhook.setIdField('myIdField) and $webhook.setKeyField('myKeyField').

activityToFolder(activity, toFolder)

Returns whether the given activity is a move to the specified folder (ie: record moved from a folder into this one)

activityFromFolder(activity, toFolder)

Returns whether the given activity is a move from the specified folder (ie: record moved from this folder this another one)

API Docs

Full documentation

Keywords

FAQs

Last updated on 17 Oct 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc