env-now
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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", ",");

Readme

Keywords

none

Package Sidebar

Install

npm i env-now

Weekly Downloads

4

Version

1.0.2

License

MIT

Unpacked Size

5.63 kB

Total Files

5

Last publish

Collaborators

  • driverjb