luckydrq / composed-store

Composed store inspired by koa-compose

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

composed-store

Composed store inspired by koa-compose

NPM version NPM download

Install

$ npm i composed-store -S

Usage

const { createStore } = require('composed-store');

// create store instance and compose with sub stores. 
const store = createStore();
store.add(new Store_Impl1());
store.add(new Store_Impl2());
store.add(new Store_Impl3());

// get
const value = await store.get({ query: { key: 'foo' }});

// set
await store.set('a', 'b');

Notice: the first arg in .get() is wrapped as Koa-Context-Like object

About

Composed store inspired by koa-compose

License:MIT License


Languages

Language:TypeScript 96.0%Language:JavaScript 4.0%