README
hemera-env
Hemera plugin to check environment variables
Install
npm install --save hemera-env
Usage
const hemeraEnv = require('hemera-env')
const schema = {
type: 'object',
required: [ 'PORT' ],
properties: {
PORT: {
type: 'string',
default: 3000
}
}
}
const options = {
confKey: 'env', // optional, default: 'env'
schema: schema,
data: data // optional, default: process.env
}
hemera
.register(hemeraEnv, options)
.ready(() => {
console.log(hemera.env)
// output: { PORT: 3000 }
})
This module is a wrapper around env-schema so, to read .env
file you must set the dotenv
in options:
const options = {
dotenv: true // will read .env in root folder
}
// or, pass config options avalible on dotenv module
const options = {
dotenv: {
path: `${__dirname}/.env`
debug: true
}
}
NB: internally this plugin force to not have additional properties, so the additionalProperties
flag is forced to be false