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

export const minioConfig = registerAs("minio", () => ({
  endPoint: process.env.MINIO_ENDPOINT || "minio-dev.smart.aaca.gov.et",
  port: parseInt(process.env.MINIO_PORT || "443", 10),
  useSSL: process.env.MINIO_USE_SSL !== "false",
  accessKey: process.env.MINIO_ACCESS_KEY || "",
  secretKey: process.env.MINIO_SECRET_KEY || "",
  bucket: process.env.MINIO_BUCKET || "fhc",
  // Preset the region so presignedGetObject signs URLs locally. Without it the
  // minio client fires a live GetBucketLocation request to the endpoint on every
  // sign — which blocks (no timeout) when MinIO is slow/unreachable and hangs
  // API responses that reload a booking's files (e.g. staff accept).
  region: process.env.MINIO_REGION || "us-east-1",
}));
