env-now
v1.0.2
Published
A set of tools for loading and requiring environment variables.
Downloads
4
Readme
Simple Environment Settings
A set of tools for loading and requiring environment variables. I am using the commonly used package dotenv
to do the intial load of the .env file for a project. This includes four functions for loading settings:
Usage
const {
loadString,
loadNumber,
loadBoolean,
loadArrayString
} = require("env-now");
// Loads the environment value TEST1 as a string. If not present "defaultValue" is used
let test1 = loadString("TEST1", "defaultValue");
// Loads the environment value TEST2 as a number. If not present an error will be thrown
let test2 = loadNumber("TEST2");
// Loads the environment value TEST3 as a boolean. If not present false is used
let test3 = loadBoolean("TEST3", false);
// Loads the environment value TEST4 as an array of strings by splitting the input string
// on the comma (,) character. If not present an error will be thrown.
let test4 = loadArrayString("TEST4", ",");