Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
contentful-webhook-listener
Advanced tools
A Simple HTTP Webserver for listening to Contentful API Webhooks with JavaScript
An HTTP server for listening to Contentful API Webhooks with JavaScript. This provides a Node.js module to create a web server and then emits events for each action (create, save, autoSave, etc) that occurs in Contentful.
Contentful is a content management platform for web applications, mobile apps and connected devices. It allows you to create, edit & manage content in the cloud and publish it anywhere via powerful API. Contentful offers tools for managing editorial teams and enabling cooperation between organizations.
Webhooks in Contentful can notify you or someone else when content has changed by calling a preconfigured HTTP endpoint. This can be used for notifications, static site generators or other forms of post-processing sourced from Contentful.
Setup a custom callback that executes on-demand and it will receive the latest version of the Entry, Asset, or Content Type for each create
, save
, autoSave
, archive
, unarchive
, or publish
event in Contentful. The unpublish
and delete
events in Contentful send a DeletedEntry or DeletedAsset payload.
See the Contentful Content Management API documentation for more details on their webhooks.
Pair this with ngork for local development, or a server behind a firewall, that responds to actions in Contentful or consider the contentful-webhook-tunnel module which automates the whole process.
If you are looking for a ruby gem with similar functionality, check out contentful-webhook-listener.
npm install contentful-webhook-listener
var listener = require("contentful-webhook-listener");
var webhook = listener.createServer();
var port = 5000;
webhook.on("publish", function (payload) {
console.log(payload);
});
webhook.listen(port);
listener
extends the http
module, so all the methods, properties, and events from the http
module are available on the listener
module.
createServer()
accepts a options argument in addition to the standard requestListener function. The options argument accepts a auth
property which will enable and enforce HTTP Basic Authentication. The auth
property value should be the username and password in <username>:<password>
format.
var listener = require("contentful-webhook-listener");
var webhook = listener.createServer({
"auth": "username:password"
}, function requestListener (request, response) {
console.log("request received");
});
var port = 5000;
webhook.on("publish", function (payload) {
console.log(payload);
});
webhook.listen(port, function callback () {
console.log("server is listening");
});
The payload returned has the following properties for the create
, save
, autoSave
, archive
, unarchive
, or publish
events. Sample data from the Contentful API sample space with cats.
{
"contentType": "cat",
"fields": {
"name": {
"en-US": "Nyan Cat"
},
"likes": {
"en-US": [
"rainbows",
"fish"
]
},
"color": {
"en-US": "rainbow"
},
"bestFriend": {
"type": "Link",
"linkType": "Entry",
"id": "happycat"
},
"birthday": {
"en-US": "2011-04-04T22:00:00+00:00"
},
"lives": {
"en-US": 1337
},
"image": {
"type": "Link",
"linkType": "Asset",
"id": "nyancat"
}
},
"id": "cat_nyancat",
"kind": "Entry",
"origin": "ContentManagement",
"space": "cfexampleapi",
"sys": {
"space": {
"sys": { }
},
"type": "Entry",
"contentType": {
"sys": { }
},
"id": "cat_nyancat",
"revision": 1,
"createdAt": "2016-10-24T19:48:51.128Z",
"updatedAt": "2016-11-03T03:12:28.855Z"
},
"webhookName": "localhost"
}
The payload has the following properties for the unpublish
and delete
events:
{
"contentType": "cat",
"fields": null,
"id": "cat_nyancat",
"kind": "Entry",
"origin": "ContentManagement",
"space": "cfexampleapi",
"sys": {
"space": {
"sys": { }
},
"type": "DeletedEntry",
"contentType": {
"sys": { }
},
"id": "cat_nyancat",
"revision": 2,
"createdAt": "2016-11-03T03:10:55.676Z",
"updatedAt": "2016-11-03T03:10:55.676Z",
"deletedAt": "2016-11-03T03:10:55.676Z"
},
"webhookName": "localhost"
}
1.0.4 — October 22, 2019
files
to package.json so only necessary files are included in npm tarball1.0.3 — October 22, 2019
1.0.2 — November 8, 2016
1.0.1 — November 3, 2016
1.0.0 — November 3, 2016
contentful-webhook-listener.js is available under the MIT License.
FAQs
A Simple HTTP Webserver for listening to Contentful API Webhooks with JavaScript
The npm package contentful-webhook-listener receives a total of 272 weekly downloads. As such, contentful-webhook-listener popularity was classified as not popular.
We found that contentful-webhook-listener demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.