@ltv/env
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

env

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.

Features

  • 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

Installation

npm install @ltv/env

Usage

const env = require('@ltv/env')
import env from '@ltv/env'

env.string

env.string(key: string, defaultValue?: string): string

env.int

env.int(key: string, defaultValue?: number): number

env.float

env.float(key: string, defaultValue?: number): number

env.bool

env.bool(key: string, defaultValue?: boolean): boolean

env.array

env.array(key: string, defaultValue?: string[]): string[]

env.json

env.json(key: string, defaultValue?: object): object

env.date

env.date(key: string, defaultValue?: Date): Date

Dependencies (0)

    Dev Dependencies (26)

    Package Sidebar

    Install

    npm i @ltv/env

    Weekly Downloads

    74

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    19.9 kB

    Total Files

    13

    Last publish

    Collaborators

    • lucduong