1.0.0 • Published 9 months ago

@kakang/fastify-config v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@kakang/fastify-config

Continuous Integration NPM version

This plugin use env-schema to read the .env file and provides the value through variables and fastify plugin.

Install

npm install @kakang/fastify-config --save

yarn add @kakang/fastify-config

Usage

import { build } from '@kakang/fastify-config'

// you need to explicit type it yourself
declare modules 'fastify' {
  interface FastifyInstance {
    config: {
      FOO: string
    }
  }
}

const { env, plugin } = build({
  schema: {
    type: 'object',
    properties: {
      FOO: { type: 'string' }
    }
  },
  data: process.env
  dotenv: true
})

fastify.register(plugin)

fastify.config // here is the env value
1.0.0

9 months ago

0.0.1

2 years ago