Official Storyblok Node.js client
This client will provide you some helpers for the Storyblok publishing API.
This repository has been inspired by https://github.com/schornio/node-storyblok. Big thanks to Thomas Schorn for this awesome package.
Install
npm install storyblok-node-client
Usage
Storyblok
Class Parameters
config
ObjectprivateToken
String, The private token you can find in your space dashboard at https://app.storyblok.comcache
Objecttype
String,filesystem
ormemory
path
String, required if you usefilesystem
as type
- (
endpoint
optional)
Example
// 1. Require the Storyblok node clientconst StoryblokClient = ; // 2. Initialize the client with the private key // from your space dashboard at https://app.storyblok.comlet Storyblok = privateToken: 'xf5dRMMjltLzKOcNgMaU9Att';
Activating request cache
The Storyblok nodejs client comes with a caching mechanism.
When initializing the Storyblok client you can define a cache provider for caching the requests on the filesystem or in memory.
To clear the cache you can call Storyblok.flushCache();
.
// For a filesystem cache the path parameter is mandatorylet Storyblok = privateToken: 'xf5dRMMjltLzKOcNgMaU9Att' cache: type: 'filesystem' path: './public/datastorage/' ; // For the memory cache only the type paramter is requiredlet Storyblok = privateToken: 'xf5dRMMjltLzKOcNgMaU9Att' cache: type: 'memory' ;
Storyblok#get
Method Parameters
[return]
Promise, Objectresponse
path
String, Path (can bestories
,stories/*
,tags
,datasources
,links
)options
Object, Options can be found in the API documentation.
Example
Storyblok ;
Storyblok#flushCache
Method Parameters
[return]
Object, returns the Storyblok client
Example
Storyblok;
Contribution
Fork me on Github