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

1.0.0 • Public • Published

Extract envs from process.env

import { Env } from '@hastom/env-extractor'

// num resolves as number
const num = Env.number('PORT').default(3030).get()
// str resolves as string
const str = Env.string('API_KEY').required().get()
// bool resolves as boolean | undefined 
// because nor default nor required were set
const bool = Env.boolean('IS_DEV').get()
// json resolves as { isNice: boolean } | undefined
const json = Env.json<{ isNice: boolean }>('NICE_ENV').get()

This package does not set envs to process.env use dotenv package with it

Package Sidebar

Install

npm i @hastom/env-extractor

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

6.11 kB

Total Files

5

Last publish

Collaborators

  • hastom