fastify-env
Fastify plugin to check environment variables
Install
npm install --save fastify-env
Usage
const fastify = require('fastify')()
const fastifyEnv = require('fastify-env')
const schema = {
type: 'object',
required: [ 'PORT' ],
properties: {
PORT: {
type: 'string',
default: 3000
}
}
}
const options = {
confKey: 'config',
schema: schema,
data: data
}
fastify
.register(fastifyEnv, options)
.ready((err) => {
if (err) console.error(err)
console.log(fastify.config)
})
NB: internally this plugin force to not have additional properties, so the additionalProperties
flag is forced to be false
Acknowledgements
Kindly sponsored by Mia Platform