storyblok-ts-client
TypeScript icon, indicating that this package has built-in type declarations

4.7.0 • Public • Published

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

ApiClient
Storyblok
StoryblokTS

Functions

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

Generate buffered image (image compression and resize is applied accordingly).

resizeImage(image, sizeLimit)Promise

Resize a sharp object

ApiClient

Kind: global class
Implements: IStoryblokClass
Export:

new ApiClient(apiToken, spaceId)

Management API wrapper around Storyblok class.

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

Object that contains API methods for asset folder operations

Kind: instance property of ApiClient
Read only: true

assetFolders.create ⇒ Promise

Create an asset folder.

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

Delete a specific asset folder.

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

Delete all existing asset folders.

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

assetFolders.get ⇒ Promise

Get a specific asset folder.

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

Get asset folders by matching asset folders names to the supplied string.

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

Get existing asset folders.

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

apiClient.assets

Object that contains API methods for asset operations

Kind: instance property of ApiClient
Read only: true

assets.count ⇒ Promise

Get total number of existing assets.

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

assets.createFromImage ⇒ Promise

Create an asset and upload the physical file.

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

Delete a specific asset.

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

Delete all existing assets.

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

assets.get ⇒ Promise

Get a specific asset.

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>>

Get asset on a specific pagination page number.

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

Find a specific asset by its public url.

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

List all existing assets.

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

assets.register ⇒ Promise

Register a Storyblok asset.

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

Upload a registered asset with failure-retry (20 retries and incremental delay period of 1250ms with +/- 500ms variance).

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

Object that contains API methods for component operations

Kind: instance property of ApiClient
Read only: true

components.create ⇒ Promise

Create a component.

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

Delete a specific component.

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

Delete existing components.

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

components.get ⇒ Promise

Fetch for a specific component.

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

List existing components.

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

components.update ⇒ Promise

Update a component.

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

Create a component.

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

Object that contains API methods for space operations

Kind: instance property of ApiClient
Read only: true

spaces.get ⇒ Promise

Get information on the working Storyblok space.

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

apiClient.stories

Object that contains API methods for story operations

Kind: instance property of ApiClient
Read only: true

stories.count ⇒ Promise

Get total number of existing stories (including folders).

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

stories.countPages ⇒ Promise

Get total pagination page count.

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

Create a story.

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

Delete a specific story.

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

Delete all existing stories.

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

stories.get ⇒ Promise

Get a specific story.

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

Get stories on a pagination page.

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

List all existing stories.

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

stories.publish ⇒ Promise

Publish a specific story.

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

Publish all unpublished stories.

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

stories.reorder ⇒ Promise

Update a story's sequential order.

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

Update a story.

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

Publish all unpublished stories.

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

apiClient.countAssets ⇒ Promise

Get total number of existing assets.

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

apiClient.countStories ⇒ Promise

Get total number of existing stories (including folders).

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

apiClient.countStoryPages ⇒ Promise

Get total pagination page count.

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

Create an asset folder.

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

Create an asset and upload the physical file.

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

Create a story.

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

Delete a specific asset.

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

Delete a specific asset folder.

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

Delete a specific component.

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

Delete a specific story.

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

Delete all existing asset folders.

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

apiClient.deleteExistingAssets ⇒ Promise

Delete all existing assets.

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

apiClient.deleteExistingComponents ⇒ Promise

Delete existing components.

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

apiClient.deleteExistingStories ⇒ Promise

Delete all existing stories.

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

apiClient.getAsset ⇒ Promise

Get a specific asset.

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

Find a specific asset by its public url.

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

Get a specific asset folder.

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

Get asset folders by matching asset folders names to the supplied string.

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

Fetch for a specific component.

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

List all existing assets.

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

apiClient.getExistingComponents ⇒ Promise

List existing components.

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

apiClient.getExistingAssetFolders ⇒ Promise

Get existing asset folders.

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

apiClient.getExistingStories ⇒ Promise

List all existing stories.

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

apiClient.getSpace ⇒ Promise

Get information on the working Storyblok space.

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

apiClient.getStoriesByPage ⇒ Promise

Get stories on a pagination page.

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

Publish a specific story.

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

Register a Storyblok asset.

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

Update a story's sequential order.

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

Update a component.

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

Update a story.

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

Upload a registered asset with failure-retry (20 retries and incremental delay period of 1250ms with +/- 500ms variance).

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>>

Get asset on a specific pagination page number.

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)

A class to provide basic CRUD request methods to Storyblok's management API with failure-retry options and built-in request throttling. Uses axios library to facilitation the API calls.

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>

DELETE request method.

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>

GET request method.

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>

POST request method.

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>

PUT request method.

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])

This is a thin wrapper for the Storyblok API's to use in Node.js and the browser. It is a typescript conversion of the Universal Javascript SDK library (https://www.npmjs.com/package/storyblok-js-client).

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

Generate buffered image (image compression and resize is applied accordingly).

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

Resize a sharp object

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

Package Sidebar

Install

npm i storyblok-ts-client

Weekly Downloads

1

Version

4.7.0

License

MIT

Unpacked Size

6.19 MB

Total Files

366

Last publish

Collaborators

  • juniorcitizen