bconf

1.0.0 • Public • Published

bconf

This model can help config your disturbed app easily. Whenever you set, get, delete and clear the configure, it will work to your local config cache directly, storing in your store, which is convenient.

Install

npm install bconf --save

Quick Start

const Redis = require('ioredis');
 
const Config = require('bconf');
const RedisStore = Config.RedisStore;
 
const redis = new Redis();
const config = new Config({
  store: new RedisStore({
    client: redis
  })
});
 
 
await config.load();
 
config.set('redis.port', 6379);
config.set('redis.host', '127.0.0.1');
 
config.get('redis')
// output {host: '127.0.0.1', port: 6379}

API

constructor(appname, options)

  • appname a string used for config store name.
  • options
    • interval ms interval of pull config from store .
    • store config store instance. It can be any Object that has the methods load, set, get, delete, clear.

load()

config loads from store before startup your app.

get(key)

get config value from store.

set(key, value)

it will save to local cache firstly, then it will save to your store.

delete(key)

firstly delete cache and then your store

clear()

firstly clear cache and then your store

Test

npm install
 
npm test

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    6
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    6

Package Sidebar

Install

npm i bconf

Weekly Downloads

6

Version

1.0.0

License

ISC

Last publish

Collaborators

  • bitebit