import { Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { ServeStaticModule } from '@nestjs/serve-static'; import { join } from 'path'; import { configurations } from './config'; import { PrismaService } from './infrastructure/persistence/prisma/prisma.service'; import { AppVersionMapper } from './infrastructure/persistence/mappers/app-version.mapper'; import { AppVersionRepositoryImpl } from './infrastructure/persistence/repositories/app-version.repository.impl'; import { APP_VERSION_REPOSITORY } from './domain/repositories/app-version.repository'; import { FileStorageService } from './infrastructure/storage/file-storage.service'; import { PackageParserService } from './infrastructure/parsers/package-parser.service'; import { CheckUpdateHandler } from './application/queries/check-update/check-update.handler'; import { ListVersionsHandler } from './application/queries/list-versions/list-versions.handler'; import { GetVersionHandler } from './application/queries/get-version/get-version.handler'; import { CreateVersionHandler } from './application/commands/create-version/create-version.handler'; import { UpdateVersionHandler } from './application/commands/update-version/update-version.handler'; import { DeleteVersionHandler } from './application/commands/delete-version/delete-version.handler'; import { ToggleVersionHandler } from './application/commands/toggle-version/toggle-version.handler'; import { UploadVersionHandler } from './application/commands/upload-version/upload-version.handler'; import { VersionController } from './api/controllers/version.controller'; import { MobileVersionController } from './api/controllers/mobile-version.controller'; import { HealthController } from './api/controllers/health.controller'; import { DownloadController } from './api/controllers/download.controller'; // Notification imports import { NotificationMapper } from './infrastructure/persistence/mappers/notification.mapper'; import { NotificationRepositoryImpl } from './infrastructure/persistence/repositories/notification.repository.impl'; import { NOTIFICATION_REPOSITORY } from './domain/repositories/notification.repository'; import { AdminNotificationController, MobileNotificationController } from './api/controllers/notification.controller'; // User Management imports import { UserQueryRepositoryImpl } from './infrastructure/persistence/repositories/user-query.repository.impl'; import { USER_QUERY_REPOSITORY } from './domain/repositories/user-query.repository'; import { UserController } from './api/controllers/user.controller'; import { UserEventConsumerService } from './infrastructure/kafka/user-event-consumer.service'; @Module({ imports: [ ConfigModule.forRoot({ isGlobal: true, load: configurations, }), // Serve static files from uploads directory ServeStaticModule.forRoot({ rootPath: join(process.cwd(), process.env.UPLOAD_DIR || 'uploads'), serveRoot: '/uploads', }), ], controllers: [ VersionController, MobileVersionController, HealthController, DownloadController, AdminNotificationController, MobileNotificationController, UserController, ], providers: [ PrismaService, AppVersionMapper, FileStorageService, PackageParserService, { provide: APP_VERSION_REPOSITORY, useClass: AppVersionRepositoryImpl, }, // Query Handlers CheckUpdateHandler, ListVersionsHandler, GetVersionHandler, // Command Handlers CreateVersionHandler, UpdateVersionHandler, DeleteVersionHandler, ToggleVersionHandler, UploadVersionHandler, // Notification NotificationMapper, { provide: NOTIFICATION_REPOSITORY, useClass: NotificationRepositoryImpl, }, // User Management { provide: USER_QUERY_REPOSITORY, useClass: UserQueryRepositoryImpl, }, UserEventConsumerService, ], }) export class AppModule {}