Skip to content

nodeboot/advanced-settings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

advanced-settings

Read application settings using advanced strategies like environment variables instead:

  • .env
  • hardcoded values in nodejs modules/classes

Requirements

  • nodejs >= 10

Usage

  • Create a file called: application.json at the root of workspace
{
  "foo": "${FOO_VALUE}",
  "bar": "baz"
}
  • expose required environment variables
export FOO_VALUE=imthefoovalue
  • add this snippet at the beginning of your application
const EnvSettings = require("advanced-settings").EnvSettings;
var envSettings = new EnvSettings();
var settings = envSettings.loadJsonFileSync("application.json", "utf8");
console.log(settings.foo);
  • expose the settings variable to your application using your own approach.

  • You can also use it as a promise

await envSettings.loadJsonFile("application.json", "utf8");

Inspiration

Contributors


JRichardsz

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published