Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stackbit/contentful-listener
Contentful's content listener based on Contentful's sync API
https://github.com/stackbit/contentful-listener
Last synced: 19 days ago
JSON representation
Contentful's content listener based on Contentful's sync API
- Host: GitHub
- URL: https://github.com/stackbit/contentful-listener
- Owner: stackbit
- Created: 2021-12-16T23:17:30.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-20T12:51:40.000Z (almost 3 years ago)
- Last Synced: 2024-10-27T22:59:44.611Z (24 days ago)
- Language: TypeScript
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Contentful Listener
The Contentful listener listens for content changes in Contentful and invokes the provided callback when such changes occur.
You can use this listener with [Nextjs Hot Content Reload](https://github.com/stackbit/nextjs-hot-content-reload) package when working locally to "hot reload" your browser with fresh content.
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
}
});contentfulListener.start();
```The `result` is a an object having the following interface, very similar to Contentful's [Sync API response](https://contentful.github.io/contentful.js/contentful/9.1.5/Sync.html#.SyncCollection):
```typescript
export interface CallbackResponse {
entries: Array>;
assets: Array;
deletedEntries: Array>;
deletedAssets: Array;
}
```