NodeJS safe environment parser. Compatible with TypeScript.
In this version,
- I have removed dotenv support. If you want to use dotenv, please use the previous version. Otherwise, you should install the dotenv package yourself.
- I have removed the lodash.has and lodash.trim dependencies, and the package size has been reduced. There is no dependency anymore.
- Safe environment parser
- Compatible with TypeScript
With typescript, if you're using are not mentioning the default value, the return type will be T | undefined
.
Otherwise, the return type will be T
.
e.g.
const foo = env.string('FOO') // foo: string | undefined
const bar = env.string('BAR', 'bar') // bar: string
npm install @ltv/env
const env = require('@ltv/env')
import env from '@ltv/env'
env.string(key: string, defaultValue?: string): string
env.int(key: string, defaultValue?: number): number
env.float(key: string, defaultValue?: number): number
env.bool(key: string, defaultValue?: boolean): boolean
env.array(key: string, defaultValue?: string[]): string[]
env.json(key: string, defaultValue?: object): object
env.date(key: string, defaultValue?: Date): Date