Manage environment variables and load it from file. Part of Zenox Framework
# Comment
NAME=rcfile
VERSION=1
WORKS=trueThe usage of the module not depend of Zenox framework and can use it in your NodeJS program.
npm install --save @zenox/envAll the examples are in ES6/ES2015 of Javascript and Typescript. To use all the features of Typescript, you can use the generic param on load function.
Get value from environment variables.
declare function get(name: string): any;import {get} from '@zenox/env';
let data = env.get('EXAMPLE');Get value as string from environment variables.
declare function getString(name: string): string;import {getString} from '@zenox/env';
let data = env.getString('EXAMPLE');Get value as number (integer) from environment variables.
declare function getInt(name: string): number;import {getInt} from '@zenox/env';
let data = env.getInt('EXAMPLE');Get value as number (float) from environment variables.
declare function getFloat(name: string): number;import {getFloat} from '@zenox/env';
let data = env.getFloat('EXAMPLE');Get value as boolean from environment variables.
declare function getBoolean(name: string): boolean;import {getBoolean} from '@zenox/env';
let data = env.getBoolean('EXAMPLE');Get if exists environment variable.
declare function exists(name: string): boolean;import {exists} from '@zenox/env';
let exists = env.exists('EXAMPLE');Get if exists environment variable and is string.
declare function existsString(name: string): boolean;import {existsString} from '@zenox/env';
let exists = env.existsString('EXAMPLE');Get if exists environment variable and is number (integer).
declare function existsInt(name: string): boolean;import {existsInt} from '@zenox/env';
let exists = env.existsInt('EXAMPLE');Get if exists environment variable and is number (float).
declare function existsFloat(name: string): boolean;import {existsFloat} from '@zenox/env';
let exists = env.existsFloat('EXAMPLE');Get if exists environment variable and is boolean.
declare function existsBoolean(name: string): boolean;import {existsBoolean} from '@zenox/env';
let exists = env.existsBoolean('EXAMPLE');Add value to environment variables.
declare function add(name: string, value: any): void;import {add} from '@zenox/env';
add('EXAMPLE', 'FOO');Remove value from environment variables.
declare function remove(name: string): void;import {remove} from '@zenox/env';
remove('EXAMPLE');Load file and set values to environment variables. Importing package, it tries to load .envrc file.
declare function load(file: string = '.envrc', encoding: string = 'utf8'): Promise<void>;import {load} from '@zenox/env';
load('.examplerc', 'utf8').then(() => {
...
});The source code of the current repository are launched with MIT License.