denoland / denoland/std

Updating dotenv `load` and `loadSync` with assertion + type inference

Open
#6,388 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3.6k
Forks
681
PR merge metrics
No merged PRs in 30d

Description

Thoughts on updating the `load` and `loadSync` functions such that an `assertExists` option could be supplied (which would then inform the returned env record)?

```ts
import { load } from "@std/dotenv"

const env = await load({
assertExists: ["STRIPE_API_KEY", "OPENAI_API_KEY", "DATABASE_URL"]
})

env satisfies {
STRIPE_API_KEY: string
OPENAI_API_KEY: string
DATABASE_URL: string
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.