import { registerAs } from "@nestjs/config";

export default registerAs("app", () => ({
  port: parseInt(process.env.PORT ?? "3003", 10),
  /**
   * Shared secret for service-to-service auth (apps -> /payments/*, payment -> mark-paid).
   * Required in production; in development an empty value disables the guard with a warning.
   * TODO: integrate @tria-plc IAM / mTLS as the long-term mechanism (docs/payment-service §14).
   */
  serviceAuthToken: process.env.SERVICE_AUTH_TOKEN ?? "",
  reconciliation: {
    /** How often the stale-intent sweep runs. */
    sweepIntervalMs: parseInt(
      process.env.RECONCILE_SWEEP_INTERVAL_MS ?? "60000",
      10,
    ),
    /** An intent is "stale" when non-terminal and untouched for this long. */
    staleAfterMs: parseInt(process.env.RECONCILE_STALE_AFTER_MS ?? "60000", 10),
    batchSize: parseInt(process.env.RECONCILE_BATCH_SIZE ?? "20", 10),
  },
}));
