A simple and smart config loader
The package takes a JSON config file and returns a parsed config object. Sconfigger knows to automatically parse values with $ sign followed by capital letters from the process environment.
const sconfigger = require("sconfigger");
const config = sconfigger("app.config.json"); // Default config file name is equivalent to <mainModuleName>.config.json. There is no need to specify this path.
npm install sconfigger --save
"app.config.json" contains the following JSON:
{
"db": {
"host": "$DATABASE_HOST",
"username": "$DATABASE_USER",
"password": "$DATABASE_PASSWORD",
},
"safe": "I am just a regular text"
}
Where $DATABASE_HOST, $DATABASE_USER, $DATABASE_PASSWORD will be set in the process env.