package
Fastify plugin for env config
npm install @kakang/fastify-configGitHub-flavored package documentation.
Across all versions, last 30 days.
60 in 30 days
Runtime metadata.
Tagged topics.
Estimated unpacked size across 8 packages.
1.4 MB
Includes dependencies.
This plugin use env-schema to read the .env file and provides
the value through variables and fastify plugin.
npm install @kakang/fastify-config --save
yarn add @kakang/fastify-configimport { 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