botify-sdk-middlewares

0.18.1 • Public • Published

botify-sdk-middlewares

NPM Version Build Status

This package contains multiple middlewares allowing to customize and optimize Botify SDK's behaviour. Including local storage caching, request dedupling, api result post processing.

Installation

npm install --save botify-sdk-middlewares

You’ll also need the Botify SDK (core).

npm install --save botify-sdk

UMD bundle

An UMD bundle is available in dist/botify-sdk-middlewares.min.js. It means you can use the lib with any module loader, including Browserify and RequireJS. It exposes the global variable BotifySDKMiddlewares.

<script src="/node_modules/botify-sdk-middlewares/dist/botify-sdk-middlewares.min.js"></script>

Usage

Use applyMiddleware function to apply middlewares you need.

import { applyMiddleware, apiErrorMiddleware, lscacheMiddleware } from 'botify-sdk-middlewares';
import baseSdk from 'botify-sdk';
 
const sdk = applyMiddleware(
  apiErrorMiddleware,
  lscacheMiddleware()
)(baseSdk);

<!> Becareful: order maters. (read middleware's documentation requirement section).

Documentation

Note: examples are written with ES6 syntax but nothing prevents you to use this lib (and create middlewares) with plain old school JavaScript.

Commands

  • npm run lint: lint sources and tests using ESlint.
  • npm test: launch tests
  • npm run test:watch: watch files and execute the tests whenever sources or tests change.

Influences

The middleware pattern used in this package has been greatly inspired by Redux middlewares.

Package Sidebar

Install

npm i botify-sdk-middlewares

Weekly Downloads

6

Version

0.18.1

License

MIT

Unpacked Size

277 kB

Total Files

39

Last publish

Collaborators

  • botify