3.0.3 • Published 3 years ago

beanify-env v3.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

beanify-env

Tools for loading and checking environment variables

Install

npm i beanify-env --save

with yarn

yarn add beanify-env

Usage

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 = 911

Options

  • schema: (required) environment variable schema.check here
  • data: value of custom data
  • env: whether to load system environment variables.default true
  • dotenv: whether to load the intermediate environment variable of .env file.check here

Decorators

  • $env: gets the converted environment variable
3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

1.0.1

4 years ago

1.0.0

4 years ago