Deno Safe Env is a utility for securely managing environment variables in Deno applications.
- Securely load environment variables
- Type-safe access to environment variables
- Easy integration with Deno projects
To install Deno Safe Env, use the following command:
deno add jsr:@safe-env/safe-env
Import the module and use it to load and access environment variables:
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
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.