naystack - v1.5.10
    Preparing search index...

    Function getEnv

    • Reads an environment variable and throws if it's missing (unless skipCheck is true). Use this for required configuration values.

      Parameters

      • key: EnvVariable

        One of the EnvVariable enum values.

      • OptionalskipCheck: T

        If true, the function does not throw when the value is missing and returns string | undefined. Useful for optional vars (e.g. getEnv(EnvVariable.TURNSTILE_KEY, true)).

      Returns T extends true ? string | undefined : string

      The env value. When skipCheck is true, the type is string | undefined; otherwise string (throws before returning if missing).

      import { getEnv, EnvVariable } from "naystack/env";

      // Required — throws if missing:
      const signingKey = getEnv(EnvVariable.SIGNING_KEY);

      // Optional — returns undefined if missing:
      const turnstile = getEnv(EnvVariable.TURNSTILE_KEY, true);