0.1.0 • Published 4 months ago

dotenv-strict v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

dotenv-strict

dotenv-strict ensures that your environment variables are not only loaded but also validated. It ensures that specific variables are present, otherwise, it will throw an error.

Extending the well-known dotenv package, dotenv-strict adds a layer of strictness to your application's environment configuration. It's useful for making sure that essential environment variables are always set.

Installation

Since dotenv is a peer dependency, you'll need to install both dotenv and dotenv-strict:

npm i dotenv dotenv-strict

Usage

Use dotenv-strict the same way you'd use dotenv, but with an additional `strict property to enforce required variables:

import { config } from 'dotenv-strict'

const env = config({ strict: ['FOO', 'BAR'] as const })

const foo = env.parsed.FOO // string
const bar = env.parsed.BAR // string
const baz = env.parsed.BAZ // string | undefined

Missing any of the strict variables will throw an error, providing you with confidence that your environment is correctly configured.

For more detailed usage and customization, refer to the dotenv documentation.

0.1.0

4 months ago

0.0.1

8 months ago

0.0.0

9 months ago