Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.
/ gupy-env Public archive

Environment variable loader using yml files

Notifications You must be signed in to change notification settings

gupy-io/gupy-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gupy Env

Environment variable loader using yml files.

Installation

npm install gupy-io/gupy-env

Usage

Declaring variables in a file (eg. .app.yml):

# Variables available in any environment
DATABASE_HOST: '127.0.0.1'
DATABASE_PORT: '5432'

# Variables available in development environment
development:
  DATABASE_USER: 'user-dev'

# Variables available in test environment
test:
  DATABASE_USER: 'user-test'

Reading the file:

const gupyEnv = require('gupy-env');

gupyEnv.load();

console.log(process.env.DATABASE_HOST)
console.log(process.env.DATABASE_PORT)
console.log(process.env.DATABASE_USER)

Parameters

Optional configuration params:

name description default value
path path to yml file .app.yml
encoding encoding of yml file utf8
env force environment section development

Usage:

const gupyEnv = require('gupy-env');

gupyEnv.load({
  path: 'myapp.yml',
  encoding: 'iso-8859-1',
  env: 'staging',
});