Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dekelev/feathers-hubspot-webhooks
Handle HubSpot webhooks in a FeathersJS service
https://github.com/dekelev/feathers-hubspot-webhooks
feathers feathersjs hubspot webhooks
Last synced: 3 months ago
JSON representation
Handle HubSpot webhooks in a FeathersJS service
- Host: GitHub
- URL: https://github.com/dekelev/feathers-hubspot-webhooks
- Owner: dekelev
- License: mit
- Created: 2019-07-28T08:02:35.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-18T21:52:27.000Z (over 1 year ago)
- Last Synced: 2024-07-25T19:16:44.880Z (3 months ago)
- Topics: feathers, feathersjs, hubspot, webhooks
- Language: JavaScript
- Size: 977 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-feathersjs - feathers-hubspot-webhooks - Handle HubSpot webhooks in a FeathersJS service (Plugins / Utilities)
README
# feathers-hubspot-webhooks
[![Build Status](https://travis-ci.org/dekelev/feathers-hubspot-webhooks.svg?branch=master)](https://travis-ci.org/dekelev/feathers-hubspot-webhooks)
## Installation
`npm install --save feathers-hubspot-webhooks`
## Usage
```javascript
// default.json
{
"hubspot": {
"apiKey": "94d64f06-0c5d-42ed-b0c8-b9926cce7697",
"webhooks": {
"signature": {
"verify": true,
"secret": "7521a231-a773-45ed-a430-ec67d8d43dc4"
}
}
}
}
``````javascript
// app.js
const { hubspotSignatureValidationMiddleware } = require('feathers-hubspot-webhooks');if (config.hubspot.webhooks.signature.verify)
app.configure(hubspotSignatureValidationMiddleware('/hubspot/webhooks', config.hubspot.webhooks.signature.secret));// run other body-parser rules here, i.e. app.use(bodyParser.json())
``````javascript
// hubspot-webhooks.service.js
const { hubspotWebhooksService } = require('feathers-hubspot-webhooks');
const handlers = require('./hubspot-webhooks.handlers');
const hooks = require('./hubspot-webhooks.hooks');module.exports = function (app) {
app.use('/hubspot/webhooks', hubspotWebhooksService(handlers));const service = app.service('hubspot/webhooks');
service.hooks(hooks);
};
``````javascript
// hubspot-webhooks.handlers.js
module.exports = {
contact: {
async created({ event, params, app }) {
// Handle webhook
// NOTE: Whatever you return will be returned as a response to hubspot.
// If you return undefined feathers will 404 and the hook will fail
params.doSomething = true;return {};
},
updated: {
async firstname({ event, params, app }) {
// Get HubSpot object ID from `event.objectId`
// Get updated value from `event.propertyValue`return {};
},
//....
},
async deleted({ event, params, app }) {
return {};
},
},
company: {
async created({ event, params, app }) {
return {};
},
updated: {
async city({ event, params, app }) {
return {};
},
//....
},
async deleted({ event, params, app }) {
return {};
},
},
deal: {
async created({ event, params, app }) {
return {};
},
updated: {
async amount({ event, params, app }) {
return {};
},
//....
},
async deleted({ event, params, app }) {
return {};
},
},
};
``````javascript
// hubspot-webhooks.hooks.js
module.exports = {
after: {
create: [
iff(hook => hook.params.doSomething,
doSomething()
),
],
},
};
```