@pyvot360/cms
v1.0.2
Published
Client SDK for CMS360
Downloads
4
Readme
CMS360 SDK Documentation (JS)
Prerequisite: Your API Key (16 digits alphanumeric). Head over to our website to create yours for free!
Installation
Unpkg
<script src="https://unpkg.com/@pyvot360/cms" type="module" ></script>
NPM
npm i @pyvot360/cms
YARN
yarn add @pyvot360/cms
Import
```
const {ClientSDK} = require("@pyvot360/cms");
// import {ClientSDK} from "@pyvot360/cms";
const sdk = new ClientSDK('YOUR-API-KEY');
```
Methods
sdk.getAll()
(async) Fetches all articlessdk.getById(articleId: string)
(async) Fetches one article by idsdk.getByUrl(articleUrl: string)
(async) Fetches one article by url stringsdk.getTopics()
(async) Fetches all topicssdk.search(filters: ArticleFilters)
* (async) Fetches articles related to search filterssdk.viewed(articleId: string)
(async) Updates the view count of an article
Note: All methods are async (return a promise). You may choose to handle that using await
or .then()
Types & Interfaces
export declare interface Article {
id?: string;
title: string;
author: Partial<Author>;
banner: string;
content: string;
tags: string[];
stats?: ArticleStats;
dateWritten?: number;
dateEditted?: number;
isPublished: boolean;
_secondaryKey?: string;
url?: string;
}
export declare interface ArticleStats {
views: number;
}
export declare interface Author {
name?: string;
bio?: string;
email?: string;
avatar?: string;
}
export declare interface ArticleFilters {
title?: string;
tag?: string;
author?: string;
}
export declare class ClientSDK {
constructor(key: string);
getAll(): Promise<Article[]>;
getById(articleId: string): Promise<Article | undefined>;
getByUrl(articleUrl: string): Promise<Article | undefined>;
getTopics(): Promise<string[]>;
search(filters: ArticleFilters): Promise<Article[]>;
viewed(articleId: string);
}