beanify-env
TypeScript icon, indicating that this package has built-in type declarations

3.0.3 • Public • Published

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

Dependencies (2)

Dev Dependencies (14)

Package Sidebar

Install

npm i beanify-env

Weekly Downloads

0

Version

3.0.3

License

MIT

Unpacked Size

6.24 kB

Total Files

11

Last publish

Collaborators

  • beanjs