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

    Class ConfigLoader

    Loads and validates CalOohPay configuration from file system.

    This module handles loading the optional .caloohpay.json configuration file from the project root. If no config file exists, it gracefully falls back to default rates, ensuring the application works out-of-the-box.

    Configuration loading follows this priority:

    1. .caloohpay.json in current working directory
    2. .caloohpay.json in user's home directory
    3. Default rates from Constants.ts
    import { ConfigLoader } from './config/ConfigLoader';

    const loader = new ConfigLoader();
    const rates = loader.loadRates();

    console.log(`Weekday rate: ${rates.weekdayRate}`);
    console.log(`Weekend rate: ${rates.weekendRate}`);
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Loads compensation rates from config file or defaults.

      Attempts to load configuration from .caloohpay.json in the following locations:

      1. Current working directory (process.cwd())
      2. User's home directory

      If no config file is found or parsing fails, returns default rates.

      Returns RatesConfig

      Validated compensation rates configuration

      If config file exists but contains invalid rate values

      Silent fallback behaviour:

      • Missing config file → Use defaults (no error)
      • Invalid JSON → Use defaults (logs warning)
      • Invalid rate values → Throws error (business logic violation)
      const loader = new ConfigLoader();
      const rates = loader.loadRates();

      // Use rates in calculator
      const calculator = new OnCallPaymentsCalculator(
      rates.weekdayRate,
      rates.weekendRate
      );