@kakang/fastify-config
v1.0.0
Published
Fastify plugin for env config
Downloads
90
Readme
@kakang/fastify-config
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