Skip to content

davidetan/fastify-env

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastify-env

Greenkeeper badge Build Status JavaScript Style Guide

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', // optional
  schema: schema,
  data: data // optional, default: process.env
}
fastify.register(fastifyEnv, options, function (err) {
   // or fastify[options.confKey]
  console.log(fastify.config)
  // output: { PORT: 3000 }
})

NB: internally this plugin force to not have additional properties, so the additionalProperties flag is forced to be false

Acknowledgements

Kindly sponsirized by Mia Platform

About

Fastify plugin to check environment variables

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%