blua-blue-node-sdk
v1.0.6
Published
nodeJS client for blua.blue
Downloads
4
Readme
blua.blue nodeJS SDK
Easily integrate your blua.blue content into your nodeJS application.
Installation
npm i blua-blue-node-sdk
Usage
const client = require('blua-blue-node-sdk');
let articles = [], article = {};
client.init('user-name', 'password').then(async () => {
// my articles
articles = await client.getArticleList();
// a particular article
article = await client.getArticle('my-article');
});
init()
parameters
- string: userName
- string: password
- string: api-base-uri (optional, needed for self-hosted instances)
Returns a promise resolving true or rejecting false. Successful authentication results in setting
- currentUser
- token (JWT)
const client = require('blua-blue-node-sdk');
client.init('user-name', 'password').then(() => {
console.log(client.currentUser);
});
getArticleList()
parameter
- object: condition (optional)
Returns articles met by the condition object. The condition defaults to all articles by current user. Please see the blua.blue API specs to see possible conditions.
NOTE: performance/speed: This call caches the fetched articles. When gathering all articles (e.g. to render a menu / links), it is recommended to call (and wait for) this call first before retrieving a single article.
getArticle()
parameter
- string: slugOrId
Returns an article object. Accepts the UUID or the unique article-slug of an article.