CalOohPay API Documentation - v2.1.0
    Preparing search index...

    Function sanitiseEnvVariable

    • 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)

      Returns Environment

      Validated Environment object with API_TOKEN

      If neither environment variable nor override provides an API token

      // Using environment variable
      const env = sanitiseEnvVariable(process.env);

      // Using command-line override
      const env = sanitiseEnvVariable(process.env, 'cli-provided-token');