6

Github GitHub - levz0r/uconfig: Micro Configurations Reader for Masses

 3 years ago
source link: https://github.com/levz0r/uconfig
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK