env Module

The env module allows you to read, set, and verify operating system environment variables at runtime.

Importing

djazair
use env

API Reference

FunctionDescription
env.get(name)Retrieves environment variable (or Null if undefined).
env.set(name, value)Sets or updates an environment variable for the current process.
env.has(name)Returns True if the environment variable is defined.
env.all()Returns a Map of all defined environment variables.

Example Usage

djazair
use env

# Reading with a fallback default
let port = env.get("PORT")
if isNull(port) port = "8080" end

let dbUrl = env.get("DATABASE_URL")
if isNull(dbUrl) dbUrl = "sqlite://app.db" end

print("Server configured on port: ${port}")

# Setting environment variables
env.set("APP_ENV", "production")
print("Running in: ${env.get("APP_ENV")}")