https://github.com/cstrnt/safe-env
Type Safe and Developer Friendly Env vars for Deno
https://github.com/cstrnt/safe-env
deno env env-vars type-safety typescript validator
Last synced: 5 days ago
JSON representation
Type Safe and Developer Friendly Env vars for Deno
- Host: GitHub
- URL: https://github.com/cstrnt/safe-env
- Owner: cstrnt
- Created: 2024-10-09T20:26:20.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-09T21:33:25.000Z (over 1 year ago)
- Last Synced: 2026-05-26T12:45:05.260Z (18 days ago)
- Topics: deno, env, env-vars, type-safety, typescript, validator
- Language: TypeScript
- Homepage: https://jsr.io/@safe-env/safe-env
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Deno Safe Env
Deno Safe Env is a utility for securely managing environment variables in Deno applications.
## Features
- Securely load environment variables
- Type-safe access to environment variables
- Easy integration with Deno projects
## Installation
To install Deno Safe Env, use the following command:
```sh
deno add jsr:@safe-env/safe-env
```
## Usage
Import the module and use it to load and access environment variables:
```typescript
import { number, string, url, boolean } from "@safe-env/safe-env";
Deno.env.set("URL", "http://some.host");
const env = safeEnv({
PORT: number({ defaultValue: 3000 }),
HOST: string({ defaultValue: "localhost" }),
URL: url({ defaultValue: new URL("http://localhost:3000") }),
ENABLE_LOGGING: boolean(),
});
console.log(env.PORT); // 3000
console.log(env.HOST); // localhost
console.log(env.URL.href); // http://some.host/
console.log(env.ENABLE_LOGGING); // false
```
## Contributing
Contributions are welcome! Please open an issue or submit a pull request.
## License
This project is licensed under the MIT License.