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

/**
 * Mirrors the freight API's MinIO config so both apps read the same env vars and
 * behave the same against the same object store. Kept as a copy rather than a
 * shared package because the two APIs share no runtime code today, and a config
 * package for six fields would be more coupling than it saves.
 */
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 || 'edr-dev',
  // Preset the region so presignedGetObject signs URLs locally. Without it the
  // minio client fires a live GetBucketLocation request on every sign, which
  // blocks (no timeout) when MinIO is slow and would hang every thread load.
  region: process.env.MINIO_REGION || 'us-east-1',
}));
