Contentful's content listener based on Contentful's sync API
npm install @stackbit/contentful-listenerThe Contentful listener listens for content changes in Contentful and invokes the provided callback when such changes occur.
Usage:
``typescript
import { ContentfulListener } from '@stackbit/contentful-listener';
const contentfulListener = new ContentfulListener({
spaceId: process.env.CONTENTFUL_SPACE_ID,
accessToken: process.env.CONTENTFUL_PREVIEW_API_KEY,
environment: 'master',
host: 'preview.contentful.com',
pollingIntervalMs: 1000,
callback: (result: CallbackResponse) => {
// Do something
}
});
`
The result is a an object having the following interface, very similar to Contentful's Sync API response:
`typescript``
export interface CallbackResponse {
entries: Array
assets: Array
deletedEntries: Array
deletedAssets: Array
}