moh-env
environment management for moh
Feature
- Use yaml to manage env configs
- Good structured and named env configs files for different environment
- Easily to mange env variable
type
,process key
,default value
, anddescriptions
- Auto managed default values, and auto overwritten
process values
toenv configed values
todefault values
- Easy to get listed env configs description, helpful for devops and other users
- Easy manages secret env config infos
Install
# with yarn $ yarn add moh-env --save # with npm $ npm install moh-env --save
Usage
- default folder is
env
int he root of the project - in the folder should include
default.yml
,development.yml
,test.yml
,staging.yml
,production.yml
- the
default.yml
should be like below, to config the value type, env variable name, default value, and description
default.yml
# type supprot: 'string', 'number', 'Boolean', 'Date', null/~ # type, env key, default value, description serverFoo: host: ['string', 'SERVER_FOO_HOST', 'http://ole3021.me:3021','The host of server foo, eg: http://foo.com/3322'] port: ['string', 'SERVER_FOO_PORT', ~, 'The prot of server foo, eg: 3021']serverBar: host: ['string', 'SERVER_BAR_HOST', ~, 'The host of server bar, eg: http://foo.com/3322 [required]']
- Add as many environment related config as you need, the
development.yml
like below
development.yml
serverBar: host: http://ole3021.me port: 3021
Init in project
const envs = const host = envsserverBarhost
generated env configs
serverFoo: host: 'http://ole3021.me:3021' port: 3021 serverBar: host: 'http://ole3021.me'