import { Module } from '@nestjs/common';
import { CloudinaryConfigModule } from '../../../config/image-management/cloudinary/config.module';
import { CloudinaryConfigService } from '../../../config/image-management/cloudinary/config.service';
import { v2 as cloudinary } from 'cloudinary';

@Module({
  imports: [CloudinaryConfigModule],
  providers: [
    {
      provide: 'CLOUDINARY',
      useFactory: async (cloudinaryConfigService: CloudinaryConfigService) => {
        return cloudinary.config({
          cloud_name: cloudinaryConfigService.cloudName,
          api_key: cloudinaryConfigService.apiKey,
          api_secret: cloudinaryConfigService.apiSecret,
        });
      },
      inject: [CloudinaryConfigService],
    },
  ],
})
export class CloudinaryProviderModule {}
