npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

storyblok-ts-client

v4.7.0

Published

Typescript library for working with Storyblok management API.

Downloads

8

Readme

Storyblok Management API Typescript Client

typescript library for working with Storyblok management API.

npm

Description

  • consists of:

    • a basic CRUD client "Storyblok" with throttling and failure-retry
    • a wrapper library over the CRUD client "ApiClient"
    • typescript conversion of the original storyblok-js-client - "StoryblokTS"
    • abstraction classes with limited functionalities:
      • Space
      • Component
      • Story
        • FolderIndex
        • Content
        • Folder
          • RootFolder
          • Subfolder
      • Asset
      • AssetFolder
  • ApiClient methods are categorized into the following:

  • API requests are throttled

  • images are compressed and resized using sharp

  • jest is setup for testing (not fully tested)

  • the management API is not fully implemented

Installation

npm install --save storyblok-ts-client

Usage

// Basic CRUD client
const {Storyblok} = require('storyblok-ts-client')
const storyblok = new Storyblok('fake_api_token')
return storyblok.get('/12345')
  .then(res => console.log('space id:', res.data.id))
  // => space id: 12345

// Management API wrapper
const {ApiClient} = require('storyblok-ts-client')
const apiClient = new ApiClient('fake_api_token', 12345)
return apiClient.spaces.get()
  .then(space => console.log('space id:', space.id))
  // => space id: 12345

// StoryblokTS
const {StoryblokTS} = require('storyblok-ts-client')
let storyblokTS = new StoryblokTS({oauthToken: 'YOUR_OAUTH_TOKEN'})
const spaceId = 12345
storyblokTS.post(`spaces/${spaceId}/stories`, {story: {name: 'xy', slug: 'xy'}})
storyblokTS.put(`spaces/${spaceId}/stories/1`, {story: {name: 'xy', slug: 'xy'}})
storyblokTS.delete(`spaces/${spaceId}/stories/1`, null)

CLI Scripts

# development and testing
npm run dev       # runs typescript transpiler in watch mode
npm start         # runs any executable code in the index.js

# test - remember to update .env file with a test Storyblok account api token and test space id
npm run dev:test  # runs jest in watch mode
npm test          # runs jest
npm run coverage  # runs jest and check code coverage stat

# build
npm run build

# tslint
npm run lint

# prettier
npm run format

API Reference - generated with jsdoc2md

Classes

Functions

ApiClient

Kind: global class
Implements: IStoryblokClass
Export:

new ApiClient(apiToken, spaceId)

| Param | Type | Description | | --- | --- | --- | | apiToken | string | API access token. | | spaceId | number | Storyblok working space id. |

Example

const {ApiClient} = require('storyblok-ts-client')
const apiClient = new ApiClient('fake_api_token', 12345)

apiClient.assetFolders

Kind: instance property of ApiClient
Read only: true

assetFolders.create ⇒ Promise

Kind: instance property of assetFolders
Fulfil: IAssetFolder Details of the asset folder created.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | name | string | Name of asset folder to create. |

assetFolders.delete ⇒ Promise

Kind: instance property of assetFolders
Fulfil: void
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Id of asset folder to be deleted. |

assetFolders.deleteExisting ⇒ Promise

Kind: instance property of assetFolders
Fulfil: void[]
Reject: AxiosError Axios error.

assetFolders.get ⇒ Promise

Kind: instance property of assetFolders
Fulfil: IAssetFolder Asset folder information.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Id of the target asset folder. |

assetFolders.getByName ⇒ Promise

Kind: instance property of assetFolders
Fulfil: IAssetFolder[] List of matched asset folders.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | searchString | string | String to search by. |

assetFolders.getExisting ⇒ Promise

Kind: instance property of assetFolders
Fulfil: IAssetFolder[] List of existing asset folders.
Reject: AxiosError Axios error.

apiClient.assets

Kind: instance property of ApiClient
Read only: true

assets.count ⇒ Promise

Kind: instance property of assets
Fulfil: number A count of existing assets.
Reject: AxiosError Axios error.

assets.createFromImage ⇒ Promise

Kind: instance property of assets
Fulfil: string public access url of the new asset.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | data | IPendingAsset | Asset information. | | filePath | string | Absolute file path to the image. | | compress | boolean | Flag to compress image. | | sizeLimit | number | Resizing dimension limit value. |

assets.delete ⇒ Promise

Kind: instance property of assets
Fulfil: IAsset Information of the deleted asset.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Id of the asset to be deleted. |

assets.deleteExisting ⇒ Promise

Kind: instance property of assets
Fulfil: IAsset[] Information on the deleted assets.
Reject: AxiosError Axios error.

assets.get ⇒ Promise

Kind: instance property of assets
Fulfil: IAsset Details of the asset.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Id of asset to fetch. |

assets.getByPage ⇒ Promise.<Array.<IAsset>>

Kind: instance property of assets
Fulfil: IAsset[] Assets on the pagination page.
Reject: AxiosError Axios error.

| Param | Type | Default | Description | | --- | --- | --- | --- | | [page] | number | 1 | Pagination page. | | [perPage] | number | 25 | Assets per page. |

assets.getByUrl ⇒ Promise

Kind: instance property of assets
Fulfil: IAsset Matched asset.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | url | string | Url to match by. |

assets.getExisting ⇒ Promise

Kind: instance property of assets
Fulfil: IAsset[] A list of existing assets.
Reject: AxiosError Axios error.

assets.register ⇒ Promise

Kind: instance property of assets
Fulfil: IRegistration Asset registration info (used for uploading).
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | asset | IPendingAsset | Information to create asset from. | | asset.filename | string | File name to register for. | | [asset.asset_folder_id] | number | (optional) Assign a asset folder. | | [asset.id] | number | (optional) Id of existing asset to replace with this new asset. |

assets.upload ⇒ Promise

Kind: instance property of assets
Fulfil: string Access url of the uploaded asset.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | buffer | Buffer | Buffered asset data. | | registration | IRegistration | Registration info. |

apiClient.components

Kind: instance property of ApiClient
Read only: true

components.create ⇒ Promise

Kind: instance property of components
Fulfil: IComponent Details of the component that was created.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | data | IPendingComponent | Info on component to be created. |

components.delete ⇒ Promise

Kind: instance property of components
Fulfil: IComponent Details of the deleted component.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Id of component to be deleted. |

components.deleteExisting ⇒ Promise

Kind: instance property of components
Fulfil: IComponent[] A list of deleted components details.
Reject: AxiosError Axios error.

components.get ⇒ Promise

Kind: instance property of components
Fulfil: IComponent Details of the component definition.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Component id to fetch by. |

components.getExisting ⇒ Promise

Kind: instance property of components
Fulfil: IComponent[] A list of component definitions.
Reject: AxiosError Axios error.

components.update ⇒ Promise

Kind: instance property of components
Fulfil: IComponent Details of component that was updated.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | data | IComponent | Storyblok component data object with modified info. |

components.create ⇒ Promise

Kind: instance property of components
Fulfil: IComponent Details of the component that was created.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | data | IPendingComponent | Info on component to be created. |

apiClient.spaces

Kind: instance property of ApiClient
Read only: true

spaces.get ⇒ Promise

Kind: instance property of spaces
Fulfil: ISpace Working space information.
Reject: AxiosError Axios error.

apiClient.stories

Kind: instance property of ApiClient
Read only: true

stories.count ⇒ Promise

Kind: instance property of stories
Fulfil: number A count of existing stories.
Reject: AxiosError Axios error.

stories.countPages ⇒ Promise

Kind: instance property of stories
Fulfil: number Total story pagination page count.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | [perPage] | number | (optional) How many stories per page. Defaults to 25. |

stories.create ⇒ Promise

Kind: instance property of stories
Fulfil: IStory Details of story that was created.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | data | IPendingStory | Storyblok story data object. |

stories.delete ⇒ Promise

Kind: instance property of stories
Fulfil: IStory Details of the story that was deleted.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | IStory | Id of the story to be deleted. |

stories.deleteExisting ⇒ Promise

Kind: instance property of stories
Fulfil: IStory[] A list of deleted stories details.
Reject: AxiosError Axios error.

stories.get ⇒ Promise

Kind: instance property of stories
Fulfil: IStory Details of content story.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Id of the content story. |

stories.getByPage ⇒ Promise

Kind: instance property of stories
Fulfil: IStory[] A page of stories.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | page | number | Pagination page number. | | [perPage] | number | (optional) How many stories per page. Defaults to 25. |

stories.getExisting ⇒ Promise

Kind: instance property of stories
Fulfil: IStory[] A list of existing content stories.
Reject: AxiosError Axios error.

stories.publish ⇒ Promise

Kind: instance property of stories
Fulfil: IStory Details of the published story
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Id of the story to publish |

stories.publishPendings ⇒ Promise

Kind: instance property of stories
Fulfil: IStory[] List of published stories.
Reject: AxiosError Axios error.

stories.reorder ⇒ Promise

Kind: instance property of stories
Fulfil: IStory Details of the moved story.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Id of the story to be moved. | | afterId | number | Id of reference story to position after. |

stories.update ⇒ Promise

Kind: instance property of stories
Fulfil: IStory Details of story that was updated.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | data | IStory | Modified story info. |

stories.publishPendings ⇒ Promise

Kind: instance property of stories
Fulfil: IStory[] List of published stories.
Reject: AxiosError Axios error.

apiClient.countAssets ⇒ Promise

Kind: instance property of ApiClient
Fulfil: number A count of existing assets.
Reject: AxiosError Axios error.

apiClient.countStories ⇒ Promise

Kind: instance property of ApiClient
Fulfil: number A count of existing stories.
Reject: AxiosError Axios error.

apiClient.countStoryPages ⇒ Promise

Kind: instance property of ApiClient
Fulfil: number Total story pagination page count.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | [perPage] | number | (optional) How many stories per page. Defaults to 25. |

apiClient.createAssetFolder ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IAssetFolder Details of the asset folder created.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | name | string | Name of asset folder to create. |

apiClient.createAssetFromImage ⇒ Promise

Kind: instance property of ApiClient
Fulfil: string Public access url of the new asset.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | data | IPendingAsset | Asset information. | | filePath | string | Absolute file path to the image. | | compress | boolean | Flag to compress image. | | sizeLimit | number | Resizing dimension limit value. |

apiClient.createStory ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IStory Details of story that was created.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | data | IPendingStory | Storyblok story data object. |

apiClient.deleteAsset ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IAsset Information of the deleted asset.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Id of the asset to be deleted. |

apiClient.deleteAssetFolder ⇒ Promise

Kind: instance property of ApiClient
Fulfil: void
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Id of asset folder to be deleted. |

apiClient.deleteComponent ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IComponent Details of the deleted component.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Id of component to be deleted. |

apiClient.deleteStory ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IStory Details of the story that was deleted.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | IStory | Id of the story to be deleted. |

apiClient.deleteExistingAssetFolders ⇒ Promise

Kind: instance property of ApiClient
Fulfil: void[]
Reject: AxiosError Axios error.

apiClient.deleteExistingAssets ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IAsset[] Information on the deleted assets.
Reject: AxiosError Axios error.

apiClient.deleteExistingComponents ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IComponent[] A list of deleted components details.
Reject: AxiosError Axios error.

apiClient.deleteExistingStories ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IStory[] A list of deleted stories details.
Reject: AxiosError Axios error.

apiClient.getAsset ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IAsset Details of the asset.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Id of asset to fetch. |

apiClient.getAssetByUrl ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IAsset Matched asset.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | url | string | Url to match by. |

apiClient.getAssetFolder ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IAssetFolder Asset folder information.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Id of the target asset folder. |

apiClient.getAssetFolderByName ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IAssetFolder[] List of matched asset folders.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | searchString | string | String to search by. |

apiClient.getComponent ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IComponent Details of the component definition.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Component id to fetch by. |

apiClient.getExistingAssets ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IAsset[] A list of existing assets.
Reject: AxiosError Axios error.

apiClient.getExistingComponents ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IComponent[] A list of component definitions.
Reject: AxiosError Axios error.

apiClient.getExistingAssetFolders ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IAssetFolder[] List of existing asset folders.
Reject: AxiosError Axios error.

apiClient.getExistingStories ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IStory[] A list of existing content stories.
Reject: AxiosError Axios error.

apiClient.getSpace ⇒ Promise

Kind: instance property of ApiClient
Fulfil: ISpace Working space information.
Reject: AxiosError Axios error.

apiClient.getStoriesByPage ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IStory[] A page of stories.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | page | number | Pagination page number. | | [perPage] | number | (optional) How many stories per page. Defaults to 25. |

apiClient.publishStory ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IStory Details of the published story
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Id of the story to publish |

apiClient.registerAsset ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IRegistration Asset registration info (used for uploading).
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | asset | IPendingAsset | Information to create asset from. | | asset.filename | string | File name to register for. | | [asset.asset_folder_id] | number | (optional) Assign a asset folder. | | [asset.id] | number | (optional) Id of existing asset to replace with this new asset. |

apiClient.reorderStory ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IStory Details of the moved story.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | id | number | Id of the story to be moved. | | afterId | number | Reference story to position after. |

apiClient.updateComponent ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IComponent Details of component that was updated.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | data | IComponent | Storyblok component data object with modified info. |

apiClient.updateStory ⇒ Promise

Kind: instance property of ApiClient
Fulfil: IStory Details of story that was updated.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | data | IStory | Storyblok story data object with modified info. |

apiClient.uploadAsset ⇒ Promise

Kind: instance property of ApiClient
Fulfil: string Access url of the uploaded asset.
Reject: AxiosError Axios error.

| Param | Type | Description | | --- | --- | --- | | buffer | Buffer | Buffered asset data. | | registration | IRegistration | Registration info. |

apiClient.getAssetsByPage([page], [perPage]) ⇒ Promise.<Array.<IAsset>>

Kind: instance method of ApiClient
Fulfil: IAsset[] Assets on the pagination page.
Reject: AxiosError Axios error.

| Param | Type | Default | Description | | --- | --- | --- | --- | | [page] | number | 1 | Pagination page. | | [perPage] | number | 25 | Assets per page. |

Storyblok

Kind: global class
Implements: IStoryblokClass
Export:

new Storyblok(apiToken)

| Param | Type | Description | | --- | --- | --- | | apiToken | string | API access token. |

Example

const {Storyblok} = require('storyblok-ts-client')
const storyblok = new Storyblok('fake_api_token')

storyblok.delete ⇒ Promise.<any>

Kind: instance property of Storyblok

| Param | Type | Default | Description | | --- | --- | --- | --- | | [url] | string | "'/'" | Request url. | | [config] | ICustomAxiosRequestConfig | | Request config. |

Example

const {Storyblok} = require('storyblok-ts-client')
const storyblok = new Storyblok('fake_api_token')
const spaceId = 12345
const storyId = 123456
const url = `/${spaceId}/stories/${storyId}`
storyblok.delete(url, {retries: 3, retryDelay: 1000})
  .then(res => console.log('deleted story id:', res.story.id))
// => deleted story id: 123456

storyblok.get ⇒ Promise.<any>

Kind: instance property of Storyblok

| Param | Type | Default | Description | | --- | --- | --- | --- | | [url] | string | "'/'" | Request url. | | [config] | ICustomAxiosRequestConfig | | Request config. |

Example

const {Storyblok} = require('storyblok-ts-client')
const storyblok = new Storyblok('fake_api_token')
const spaceId = 12345
const url = `/${spaceId}`
storyblok.get(url, {retries: 3, retryDelay: 1000})
  .then(res => console.log('space id:', res.space.id))
// => space id: 12345

storyblok.post ⇒ Promise.<any>

Kind: instance property of Storyblok

| Param | Type | Default | Description | | --- | --- | --- | --- | | [url] | string | "'/'" | Request url. | | [data] | any | | Request data body. | | [config] | ICustomAxiosRequestConfig | | Request config. |

Example

const {Storyblok} = require('storyblok-ts-client')
const storyblok = new Storyblok('fake_api_token')
const spaceId = 12345
const url = `/${spaceId}/stories`
const story = {
  name: 'test',
  slug: 'test',
}
storyblok.post(url, {story}, {retries: 3, retryDelay: 1000})
  .then(res => console.log('new story id:', res.story.id))
// => new story id: 123456

storyblok.put ⇒ Promise.<any>

Kind: instance property of Storyblok

| Param | Type | Default | Description | | --- | --- | --- | --- | | [url] | string | "'/'" | Request url. | | [data] | any | | Request data body. | | [config] | ICustomAxiosRequestConfig | | Request config. |

Example

const {Storyblok} = require('storyblok-ts-client')
const storyblok = new Storyblok('fake_api_token')
const spaceId = 12345
const url = `/${spaceId}/stories`
const story = {name: 'test', slug: 'test'}
storyblok.post(url, {story}, {retries: 3, retryDelay: 1000})
  .then(res => {
    const newStoryId = res.story.id
    console.log('new story id:', newStoryId)
    console.log('new story name:', res.story.name)
    const updateContent = {name: 'new test', slug: 'test'}
    return storyblok.put(
      url + `/${newStoryId}`,
      {story: updateContent},
      {retries: 3, retryDelay: 1000}
    )
  })
  .then(res => console.log('updated story name:', res.story.name))
  .catch(e => console.log(e.config))
// => new story id: 123456
// => new story name: test
// => updated story name: new test

StoryblokTS

Kind: global class
Export:

new StoryblokTS(config, [rateLimit], [endpoint])

| Param | Type | Description | | --- | --- | --- | | config | any | Configurations. | | config.accessToken | string | The preview token you can find in your space dashboard at https://app.storyblok.com. | | [config.cache] | any | Cache types. | | config.cache.type | string | 'none' or 'memory'. | | config.cache.clear | string | 'auto' or 'manual'. | | [config.headers] | any | Request headers. | | [config.region] | string | Region. | | [config.https] | boolean | Switch for https. | | [config.oauthToken] | string | Management API key. | | [rateLimit] | number | Throttle value (defaults to 3 for management api and 5 for cdn api). | | [endpoint] | string | API endpoint. |

Example

// Example for using the content delivery api
// 1. Require the Storyblok client
const {StoryblokTS} = require('storyblok-ts-client')
// 2. Initialize the client with the preview
//    token from your space dashboard at
//    https://app.storyblok.com
let Storyblok = new StoryblokClient({
  accessToken: 'your_access_token'
})

// Example for using the content management api
// 1. Require the Storyblok client
const {StoryblokTS} = require('storyblok-ts-client')
const spaceId = 12345
// 2. Initialize the client with the oauth token
//    from the my account area at
//    https://app.storyblok.com
let Storyblok = new StoryblokClient({
  oauthToken: 'YOUR_OAUTH_TOKEN'
})
Storyblok.post(`spaces/${spaceId}/stories`, {story: {name: 'xy', slug: 'xy'}})
Storyblok.put(`spaces/${spaceId}/stories/1`, {story: {name: 'xy', slug: 'xy'}})
Storyblok.delete(`spaces/${spaceId}/stories/1`, null)

imageToBuffer(filePath, [compress], [sizeLimit], [forceFormat]) ⇒ Promise

Kind: global function
Fulfil: Buffer Buffered image data.
Reject: Error Error value.

| Param | Type | Description | | --- | --- | --- | | filePath | string | Absolute path to image file. | | [compress] | boolean | Flag to compress image. | | [sizeLimit] | number | Resizing dimension limit value. | | [forceFormat] | string | Force convert to a particular format. |

resizeImage(image, sizeLimit) ⇒ Promise

Kind: global function
Fulfil: Sharp Resized sharp object.
Reject: Error Error value.

| Param | Type | Default | Description | | --- | --- | --- | --- | | image | Sharp | | sharp object. | | sizeLimit | number | 640 | Size (in pixels) to limit image dimension. |

© 2018 juniorCitizen