Validates and sanitizes environment variables for API access.
This function ensures that the required API token is available, either from
the environment variables or a command-line override. It prioritizes the
command-line provided key over the environment variable.
SECURITY BEST PRACTICES:
API tokens are validated but never logged in clear text
Use ConsoleLogger for any logging needs (automatic masking enabled)
Use sanitizeError() from logger/utils before throwing/logging errors
Avoid including tokens in error messages or stack traces
Never expose token length or other metadata in validation messages
Parameters
envVars: ProcessEnv
Node.js process environment variables
OptionalapiKeyOverride: string
Optional API key provided via command-line (takes precedence)
Validates and sanitizes environment variables for API access.
This function ensures that the required API token is available, either from the environment variables or a command-line override. It prioritizes the command-line provided key over the environment variable.
SECURITY BEST PRACTICES: