beanify-env
v3.0.3
Published
beanify-env
Downloads
4
Maintainers
Readme
beanify-env
Tools for loading and checking environment variables
Install
npm i beanify-env --savewith yarn
yarn add beanify-envUsage
const Beanify = require('beanify')
const Env = require('beanify-env')
const beanify = Beanify({})
beanify
.register(Env, {
schema: {
type: 'object',
properties: {
PORT: {
type: 'number'
}
},
required: ['PORT']
},
dotenv: true
})
.ready(e => {
e && beanify.$log.error(e.message)
beanify.print()
console.log(beanify.$env) // { PORT: 911 }
})// .env
PORT = 911Options
schema: (required) environment variable schema.check heredata: value of custom dataenv: whether to load system environment variables.default truedotenv: whether to load the intermediate environment variable of.envfile.check here
Decorators
$env: gets the converted environment variable
