Skip to content

Latest commit

 

History

History
64 lines (46 loc) · 1.71 KB

README.md

File metadata and controls

64 lines (46 loc) · 1.71 KB

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