Git Product home page Git Product logo

conf-store's Introduction

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.

conf-store's People

Contributors

duro avatar greenkeeperio-bot avatar kellyrmilligan avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.