Seneca Config is a plugin for Seneca
Live configuration plugin for the Seneca framework.
Unlike static configuration, this plugin lets you store keyed configuration in your deployed persistent storage so that you can change it on the live system. This is useful for things like currency exchange rates, feature flags, A/B testing etc.
This open source module is sponsored and supported by Voxgig. |
---|
$ npm install @seneca/Config
seneca.use('Config', {})
const initRes = await seneca.post('sys:config,init:val,key:a,val:1')
// === { ok: true, key: 'a', val: 1, entry: { key: 'a', val: 1 } }
const getRes = await seneca.post('sys:config,get:val,key:a')
// === { ok: true, key: 'a', val: 1, entry: { key: 'a', val: 1 } }
const setRes = await seneca.post('sys:config,set:val,key:a,val:2')
// === { ok: true, key: 'a', val: 1, entry: { key: 'a', val: 2 } }
Review the unit tests for more examples.
debug
: booleannumparts
: numbercanon
: objectinit$
: boolean
Get a config value by key.
- key : string
Initialise a config value by key (must not exist).
- key : string
- existing : boolean (optional, default:
false
)
List config values by query.
- q : object (optional, default:
{}
)
Get a map of config values by key prefix (dot separated).
- prefix : string
Set a config value by key (must exist).
- key : string