Environment Variables β
The following basic examples show how to work with environment variables. Deno provides support for environment variables natively. The Deno.env
object provides methods to get, set, delete, and list environment variables.
Default Environment Variables β
Netzo will inject a set of default environment variables to the project at runtime.
{
"DENO_DEPLOYMENT_ID": "63be692a877dce879a4604bd-63bf3ad110ea82bec8916dd1",
"DENO_REGION": "europe-west9",
"NETZO_ENV": "production",
"NETZO_PROJECT_ID": "63be692a877dce879a4604bd",
"NETZO_PROJECT_HASH": "63bf3ad110ea82bec8916dd1",
"NETZO_PROJECT_ENTRYPOINT": "main.ts",
"NETZO_PROJECT_ENTRYPOINT_URL": "https://api.netzo.io/projects/63be692a877dce879a4604bd/main.ts",
"NETZO_PROJECT_IMPORT_MAP": "import_map.json",
"NETZO_PROJECT_IMPORT_MAP_URL": "https://api.netzo.io/projects/63be692a877dce879a4604bd/import_map.json"
}
{
"DENO_DEPLOYMENT_ID": "63be692a877dce879a4604bd-63bf3ad110ea82bec8916dd1",
"DENO_REGION": "europe-west9",
"NETZO_ENV": "production",
"NETZO_PROJECT_ID": "63be692a877dce879a4604bd",
"NETZO_PROJECT_HASH": "63bf3ad110ea82bec8916dd1",
"NETZO_PROJECT_ENTRYPOINT": "main.ts",
"NETZO_PROJECT_ENTRYPOINT_URL": "https://api.netzo.io/projects/63be692a877dce879a4604bd/main.ts",
"NETZO_PROJECT_IMPORT_MAP": "import_map.json",
"NETZO_PROJECT_IMPORT_MAP_URL": "https://api.netzo.io/projects/63be692a877dce879a4604bd/import_map.json"
}
Runtime Environments β
Netzo supports two runtime environments for projects: production
and preview
. The corresponding environment variables will be injected to the project at runtime and NETZO_ENV
will be set to either production
or preview
.
- Production:
https://{uid}.netzo.io
- Preview:
https://{deploymentId}.netzo.io
Deno.env.get() β
Get the value of an environment variable. Returns undefined
if the variable is not defined.
const name = Deno.env.get('NAME')
const name = Deno.env.get('NAME')
Deno.env.set() β
Set the value of an environment variable.
Deno.env.set('NAME', 'John')
Deno.env.set('NAME', 'John')
Deno.env.toObject() β
Get a copy of the environment variables as an object.
const env = Deno.env.toObject()
const env = Deno.env.toObject()
Deno.env.delete() β
Unset the value of an environment variable.
Deno.env.delete('NAME')
Deno.env.delete('NAME')