Skip to main content
Module

x/simple_utility/mod.ts>envGet

Useful snippet collection.
Go to Latest
function envGet
import { envGet } from "https://deno.land/x/simple_utility@v1.5.1/mod.ts";

Convert environment variable to specified type and get.

Examples

Example 1

const port = envGet("SERVER_PORT", "number", true);

Type Parameters

T extends keyof EnvType
U extends boolean

Parameters

key: string
type: T
required: U

Returns

U extends true ? EnvType[T] : EnvType[T] | undefined