{"id":15046899,"url":"https://github.com/mattdean1/contentful-sync-redis","last_synced_at":"2025-10-28T19:31:53.984Z","repository":{"id":57206472,"uuid":"101428268","full_name":"mattdean1/contentful-sync-redis","owner":"mattdean1","description":"Keep an up-to-date copy of your Contentful space in Redis","archived":false,"fork":false,"pushed_at":"2017-10-05T13:46:23.000Z","size":167,"stargazers_count":4,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-03T06:09:23.893Z","etag":null,"topics":["contentful","nodejs","npm-package","redis","sync-api"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/contentful-sync-redis","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattdean1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-25T17:46:22.000Z","updated_at":"2021-06-14T20:48:22.000Z","dependencies_parsed_at":"2022-09-04T03:21:48.539Z","dependency_job_id":null,"html_url":"https://github.com/mattdean1/contentful-sync-redis","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattdean1%2Fcontentful-sync-redis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattdean1%2Fcontentful-sync-redis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattdean1%2Fcontentful-sync-redis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattdean1%2Fcontentful-sync-redis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattdean1","download_url":"https://codeload.github.com/mattdean1/contentful-sync-redis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219860180,"owners_count":16556026,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["contentful","nodejs","npm-package","redis","sync-api"],"created_at":"2024-09-24T20:53:43.262Z","updated_at":"2025-10-28T19:31:48.676Z","avatar_url":"https://github.com/mattdean1.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/mattdean1/contentful-sync-redis.svg?branch=master)](https://travis-ci.org/mattdean1/contentful-sync-redis)\n\n# contentful-sync-redis\n\n\u003e Keep an up-to-date copy of your Contentful space in Redis\n\n#### What does this package do?\n\n- Keeps a copy of your Contentful space in Redis, using the [Contentful Sync API](https://www.contentful.com/developers/docs/concepts/sync/).\n- Provides a helper function to resolve [Links](https://www.contentful.com/developers/docs/concepts/links/) inside your entries.\n\n#### Why wouldn't I use the Contentful Javascript SDK?\n\nThe Contentful JS SDK is a only thin wrapper on top of their API, and it can be tedious to [implement the Sync API](https://www.contentful.com/developers/docs/javascript/tutorials/using-the-sync-api-with-js/) in every project.\n\n# Install\n\n```\nnpm install --save contentful-sync-redis\n```\n\n# Usage\n\n```javascript\nconst ContentfulSyncRedis = require('contentful-sync-redis')\nconst cf = new ContentfulSyncRedis({ space: 'space_id', token: 'access_token' })\ncf.getEntries()\n\t.then(entries =\u003e yourFunction(entries))\n```\n\n# API\n\n### Initialisation\n\nInitialise the module using the `new` operator, passing in the mandatory values for:\n\n - Contentful space ID\n - Contentful access token\n\n Optionally, also pass in:\n\n  - Contentful API host\n     - Default: `cdn.contentful.com`\n- Redis URL\n  - Default: `redis://localhost:6379`\n\n```javascript\nconst ContentfulSyncRedis = require('contentful-sync-redis')\nconst cf = new ContentfulSyncRedis({\n\tspace: 'string',\n\ttoken: 'string',\n\tcontentfulHost: 'optionalString',\n\tredisHost: 'optionalString',\n})\n```\n\n### Synchronisation\n\nPerform the initial download of content to Redis - it's often worth calling this just after initialisation\n\n```javascript\ncf.sync() // returns an empty promise\n```\n\n### Getting Entries\n\nReturn all entries in the Contentful space, after making sure the cache is synced.\n\nYou can use this without calling `sync()` beforehand.\n\n```javascript\ncf.getEntries() // returns a promise containing the entries\n```\n\n\n\n### Get Entries and Resolve Links\n\nA wrapper function that calls `getEntries` and then `resolveReferences`.\n\n```javascript\ncf.getResolvedEntries(entries) // returns a promise containing the resolved entries\n```\n\n### \n\n### Resolving Links\n\nDereferences links to other entries in your content and groups fields by locale. Pass in an array of entries.\n\n```javascript\ncf.resolveReferences(entries) // returns a promise containing the resolved entries\n```\n\ne.g.\n\n```javascript\ncf.resolveReferences([\n\t{\n\t  sys: { ... },\n\t  fields: {\n\t    title: {\n\t      \"en-US\": `Home`,\n\t    },\n\t    summary: {\n\t      \"en-US\": `This is the homepage, it talks about the site `,\n\t    },\n\t    sections: {\n\t      \"en-US\": [\n\t        {\n\t          sys: {\n\t            type: `Link`,\n\t            linkType: `Entry`,\n\t            id: `6Gz0vGZmAoSgOSAM2Ks4gW`,\n\t          },\n\t        },\n\t        {\n\t          sys: {\n\t            type: `Link`,\n\t            linkType: `Entry`,\n\t            id: `S9n6QORFyEeKEUaGS2Ym4`,\n\t          },\n\t        },\n\t      ],\n\t    },\n\t  },\n\t}\n])\n```\n\nReturns a Promise which resolves to:\n```javascript\n{\n  sys: { ... },\n  fields: {\n    \"en-US\": {\n      title: `Home`,\n      summary: `This is the homepage, it talks about the site `,\n      sections: [\n        {\n          sys: { ... },\n          fields: {\n            \"en-US\": {\n              title: `About us`,\n              content: `Made by Matt Dean`,\n            },\n          },\n        },\n        {\n          sys: { ... },\n          fields: {\n            \"en-US\": {\n              title: `Introduction`,\n              content: `Hi this is contentful-sync-redis`,\n            },\n          },\n        },\n      ],\n    },\n  },\n}\n```\n\nWhere 'sections' is a multi-reference field\n\n###  Logging\n\nSee the [debug module](https://www.npmjs.com/package/debug). Use the package name (`contentful-sync-redis`) as the string in the environment variable.\n\n\n# Release Map / Changelog\n\n### MVP - 0.1\n\n - [x] Implement Sync API\n - [x] `resolveReferences` helper function\n - [x] Preview API supported\n\n### 0.2\n\n - [x] Tests using Mocha\n - [x] CI integration using Travis\n - [x] Contribution guidelines\n\n### 0.3\n\n - [x] Group fields by locale\n - [x] No longer configure Redis client using an environment variable\n\n### 0.4\n\n- [x] Add sugar function to get entries and resolve references with a single call\n\n### 1.0\n\n- [ ] Support old versions of Node using webpack\n\n### Later releases / To do\n\n- Plugin functionality to allow for other databases\n- Support filtering content\n- Support assets\n\n# Contributions\n\nAll contributions welcome! Please feel free to open an issue/PR :smile:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattdean1%2Fcontentful-sync-redis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattdean1%2Fcontentful-sync-redis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattdean1%2Fcontentful-sync-redis/lists"}