@levz0r/uconfig

Micro Configurations Reader for Masses

Usage no npm install needed!

<script type="module">
  import levz0rUconfig from 'https://cdn.skypack.dev/@levz0r/uconfig';
</script>

README

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 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)