Giter Site home page Giter Site logo

getconfig's Introduction

#getconfig - config reader for node.js

Why, what, how?

This little config reader uses the NODE_ENV environment variable to determine the execution environment we're in and then reads a file that matches that name.

It will then look for a config file with the corresponding name in the same folder as the entry point of your current application. In most cases, that's the root of your project.

You can set your environment to whatever you want, but we color these nicely:

  • dev - dev_config.json
  • test - test_config.json
  • production - production_config.json

How to use it

  1. install via npm:

    npm install getconfig
  2. create your config file, for example:

    {
        "databasePassword": "something long and silly",
        "andbangClientId": "my-client-id"
    }
  3. get your config:

    // just requiring 'getconfig' will fetch and parse your JSON config
    // based on your environment. 
    var config = require('getconfig')
    
    // so you can just use it
    console.log(config.databasePassword); // outputs: "something long and silly"
    console.log(config.getconfig.env); // outputs the current environment
  4. (optional) You can also config whether you want it to log out it's environment info and whether or not to use colors in output. By adding the following to your {{some name}}_config.json file:

    {
        "getconfig": {
            "colors": false, //turns off colors
        }
    }
    {
        "getconfig": {
            "silent": true, //turns off all output
        }
    }

Extra

getconfig will also fill in the getconfig.env value with the current environment name so you can programatically determine the environment if you'd like.

License

MIT

if you dig it follow @HenrikJoreteg on twitter.

getconfig's People

Contributors

henrikjoreteg avatar nlf avatar

Watchers

 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.