Skip to main content

getNumber(variableName): number

Defined in: src/config-manager/getters.ts:188

Retrieves and validates a numeric environment variable. Parses the string value to a number and validates it's not NaN.

Parameters​

variableName​

string

The name of the environment variable to retrieve

Returns​

number

The numeric value parsed from the environment variable

Throws​

When the environment variable is missing, not a valid number, or contains only whitespace

Example​

// Environment: PORT=3000
const port = getNumber('PORT');
// Returns: 3000

// Environment: TIMEOUT=30.5
const timeout = getNumber('TIMEOUT');
// Returns: 30.5