Contentful Redis
A tiny library to map Contentful ☁️ space into Redis ⚡️
Installation
npm install cf-redis --save
Usage
Create an instance of cf-redis
by passing contentful space ID & access token.
import cfRedis from 'cf-redis';
const client = new cfRedis({
space: '<Space ID>',
accessToken: '<Access Token>',
});
API
sync
Syncs the latest space content from Contentful and dumps it in your Redis server 🎉
await client.sync();
get
Gets all data directly from Redis 🚀
const response = await client.get();
console.log(response);
You can also pass specific content type.
const response = await client.get('about');
You'll get an object with your content type ID's as keys and their values as array of content objects.
{
"<ContentType ID 1>": [{}, {}, {}],
"<ContentType ID 2>": [{}]
}
Redis Store
In Redis, the keys (content types) will be prefixed with cf-redis to uniquely identify keys created by cf-redis 🤓
License
MIT ❤