/uconfig

Micro Configurations Reader for Masses

Primary LanguageJavaScriptMIT LicenseMIT

uConfig

🤏 Micro Configurations Reader for Masses

  • The smallest configuration reader in the world.
  • Works with any JSON file as configuration source.
  • Has only one external dependency.

Getting Started

Install uConfig using npm:

npm i @levz0r/uconfig

Usage

Create a JSON file which will hold your configuration.

For example:

{
    "DB": {
        "USERNAME": "user",
        "PASSWORD": "password"
    },
    "API": {
        "ENDPOINT": "http://example.com"
    }
}

Initialize uConfig instance:

const uConfig = require("@levz0r/uconfig").default;

const config = new uConfig(/* Path to configuration JSON */);

Read configuration value:

config.get("DB.USERNAME")

Fallback value:

config.get("DB.PORT", 27017)