conf-store

1.3.2 • Public • Published

Filterable config store, based on Hapijs Confidence

Dependency Status Build Status Coverage Status

why?

I wanted a lightweight alternative to Hapijs Confidence library. I was using it in a client side project, and found it a bit heavy.

example

import ConfStore from 'conf-store'

const config = {
  apiKey: {
    "$filter": "env",
    "development": "asdfasdf",
    "staging": "asfasdf",
    "production": "asfdasd"
  }
}
const store = new Store(config)
const manifest = store.get('/', { env: process.env.NODE_ENV })
export default manifest
//manifest is an object filtered by NODE_ENV in this example

CLI

A cli is also available in order to export a filtered store to a json file to use in a client side app for example consumed by webpack.

in pakage.json scripts block:

build-config: confStore fixtures/store.js -p '/' -f env=$NODE_ENV -o dist/config.json

the first arugment is the path to the module that exports the unfiltered store.

import ConfStore from 'conf-store'

const config = {
  apiKey: {
    "$filter": "env",
    "development": "asdfasdf",
    "staging": "asfasdf",
    "production": "asfdasd"
  }
}
const store = new Store(config)

export default store

-p arg is the path you want to get from the store to export.

-f is the filter you want to apply. it will be converted to

{ env: 'development'}

to be applied against the store

-o is where the file should be output.

Readme

Keywords

Package Sidebar

Install

npm i conf-store

Weekly Downloads

1,385

Version

1.3.2

License

MIT

Unpacked Size

274 kB

Total Files

23

Last publish

Collaborators

  • kellyrmilligan