import { Module } from "@nestjs/common";
import { TypeOrmModule } from "@nestjs/typeorm";

import { FileUploadField } from "./entities/file-upload-field.entity";
import { FileUploadSetting } from "./entities/file-upload-setting.entity";
import { FileUploadSettingsController } from "./file-upload-settings.controller";
import { FileUploadSettingsRepository } from "./file-upload-settings.repository";
import { FileUploadSettingsService } from "./file-upload-settings.service";
import { FILE_UPLOAD_SETTINGS_REPOSITORY } from "./interfaces/file-upload-settings.repository.interface";

@Module({
  imports: [TypeOrmModule.forFeature([FileUploadSetting, FileUploadField])],
  controllers: [FileUploadSettingsController],
  providers: [
    FileUploadSettingsRepository,
    {
      // Bind the interface token to the concrete TypeORM repository so the
      // service can inject the abstraction (handy for tests / swap-out).
      provide: FILE_UPLOAD_SETTINGS_REPOSITORY,
      useExisting: FileUploadSettingsRepository,
    },
    FileUploadSettingsService,
  ],
  exports: [FileUploadSettingsService],
})
export class FileUploadSettingsModule {}
