import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { MulterModule } from '@nestjs/platform-express';
import { FileORM } from '../infrastructure/database/postgres/entities/file.orm';
import { FilePostgresRepository } from '../adapters/outbound/persistence/file-postgres.repository';
import { FILE_REPOSITORY } from '../domain/repositories/file.repository.interface';
import { FileController } from '../adapters/inbound/file.controller';
import { FileService } from '../application/services/file.service';
import { MinioStorageAdapter } from '../adapters/outbound/storage/minio-storage.adapter';

@Module({
  imports: [
    TypeOrmModule.forFeature([FileORM]),
    MulterModule.register({
      limits: {
        fileSize: 10 * 1024 * 1024, // 10MB for direct upload
      },
    }),
  ],
  controllers: [FileController],
  providers: [
    FileService,
    MinioStorageAdapter,
    {
      provide: FILE_REPOSITORY,
      useClass: FilePostgresRepository,
    },
  ],
  exports: [FileService, FILE_REPOSITORY],
})
export class FileModule {}
