import { S3Client } from '@aws-sdk/client-s3';
import config from '../config/config';

export const r2Endpoint = `https://${config.r2.accountId}.r2.cloudflarestorage.com`;

export const R2Client = new S3Client({
  region: 'auto',
  endpoint: r2Endpoint,
  credentials: {
    accessKeyId: config.r2.accessKeyId,
    secretAccessKey: config.r2.secretAccessKey,
  },
  // If you ever need path-style URLs instead of virtual-hosted (rare for R2), set:
  // forcePathStyle: true,
});
