diff --git a/server/src/apps/api.module.ts b/server/src/apps/api.module.ts index 04c95f1999..717b348deb 100644 --- a/server/src/apps/api.module.ts +++ b/server/src/apps/api.module.ts @@ -3,6 +3,7 @@ import { APP_GUARD, APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core'; import { ScheduleModule } from '@nestjs/schedule'; import { TypeOrmModule } from '@nestjs/typeorm'; import { ApiService } from 'src/apps/api.service'; +import { AppModule } from 'src/apps/app.module'; import { ActivityController } from 'src/controllers/activity.controller'; import { AlbumController } from 'src/controllers/album.controller'; import { APIKeyController } from 'src/controllers/api-key.controller'; @@ -24,13 +25,11 @@ import { SystemConfigController } from 'src/controllers/system-config.controller import { TagController } from 'src/controllers/tag.controller'; import { TrashController } from 'src/controllers/trash.controller'; import { UserController } from 'src/controllers/user.controller'; -import { DomainModule } from 'src/domain/domain.module'; import { AssetEntity } from 'src/entities/asset.entity'; import { ExifEntity } from 'src/entities/exif.entity'; import { AssetRepositoryV1, IAssetRepositoryV1 } from 'src/immich/api-v1/asset/asset-repository'; import { AssetController as AssetControllerV1 } from 'src/immich/api-v1/asset/asset.controller'; import { AssetService as AssetServiceV1 } from 'src/immich/api-v1/asset/asset.service'; -import { InfraModule } from 'src/infra/infra.module'; import { AuthGuard } from 'src/middleware/auth.guard'; import { ErrorInterceptor } from 'src/middleware/error.interceptor'; import { FileUploadInterceptor } from 'src/middleware/file-upload.interceptor'; @@ -38,8 +37,7 @@ import { FileUploadInterceptor } from 'src/middleware/file-upload.interceptor'; @Module({ imports: [ // - InfraModule, - DomainModule, + AppModule, ScheduleModule.forRoot(), TypeOrmModule.forFeature([AssetEntity, ExifEntity]), ], diff --git a/server/src/infra/infra.module.ts b/server/src/apps/app.module.ts similarity index 73% rename from server/src/infra/infra.module.ts rename to server/src/apps/app.module.ts index b0387ba96a..f134d33632 100644 --- a/server/src/infra/infra.module.ts +++ b/server/src/apps/app.module.ts @@ -6,9 +6,34 @@ import { ScheduleModule, SchedulerRegistry } from '@nestjs/schedule'; import { TypeOrmModule } from '@nestjs/typeorm'; import { OpenTelemetryModule } from 'nestjs-otel'; import { bullConfig, bullQueues, immichAppConfig } from 'src/config'; +import { ActivityService } from 'src/domain/activity/activity.service'; +import { AlbumService } from 'src/domain/album/album.service'; +import { APIKeyService } from 'src/domain/api-key/api-key.service'; +import { AssetService } from 'src/domain/asset/asset.service'; +import { AuditService } from 'src/domain/audit/audit.service'; +import { AuthService } from 'src/domain/auth/auth.service'; +import { DatabaseService } from 'src/domain/database/database.service'; +import { DownloadService } from 'src/domain/download/download.service'; +import { JobService } from 'src/domain/job/job.service'; +import { LibraryService } from 'src/domain/library/library.service'; +import { MediaService } from 'src/domain/media/media.service'; +import { MetadataService } from 'src/domain/metadata/metadata.service'; +import { PartnerService } from 'src/domain/partner/partner.service'; +import { PersonService } from 'src/domain/person/person.service'; +import { SearchService } from 'src/domain/search/search.service'; +import { ServerInfoService } from 'src/domain/server-info/server-info.service'; +import { SharedLinkService } from 'src/domain/shared-link/shared-link.service'; +import { SmartInfoService } from 'src/domain/smart-info/smart-info.service'; +import { StorageTemplateService } from 'src/domain/storage-template/storage-template.service'; +import { StorageService } from 'src/domain/storage/storage.service'; +import { SystemConfigService } from 'src/domain/system-config/system-config.service'; +import { TagService } from 'src/domain/tag/tag.service'; +import { TrashService } from 'src/domain/trash/trash.service'; +import { UserService } from 'src/domain/user/user.service'; import { databaseEntities } from 'src/entities'; import { databaseConfig } from 'src/infra/database.config'; import { otelConfig } from 'src/infra/instrumentation'; +import { ImmichLogger } from 'src/infra/logger'; import { IAccessRepository } from 'src/interfaces/access.repository'; import { IActivityRepository } from 'src/interfaces/activity.repository'; import { IAlbumRepository } from 'src/interfaces/album.repository'; @@ -64,7 +89,35 @@ import { TagRepository } from 'src/repositories/tag.repository'; import { UserTokenRepository } from 'src/repositories/user-token.repository'; import { UserRepository } from 'src/repositories/user.repository'; -const providers: Provider[] = [ +const services: Provider[] = [ + APIKeyService, + ActivityService, + AlbumService, + AssetService, + AuditService, + AuthService, + DatabaseService, + DownloadService, + ImmichLogger, + JobService, + LibraryService, + MediaService, + MetadataService, + PartnerService, + PersonService, + SearchService, + ServerInfoService, + SharedLinkService, + SmartInfoService, + StorageService, + StorageTemplateService, + SystemConfigService, + TagService, + TrashService, + UserService, +]; + +const repositories: Provider[] = [ { provide: IActivityRepository, useClass: ActivityRepository }, { provide: IAccessRepository, useClass: AccessRepository }, { provide: IAlbumRepository, useClass: AlbumRepository }, @@ -92,7 +145,6 @@ const providers: Provider[] = [ { provide: IMediaRepository, useClass: MediaRepository }, { provide: IUserRepository, useClass: UserRepository }, { provide: IUserTokenRepository, useClass: UserTokenRepository }, - SchedulerRegistry, ]; @Global() @@ -107,10 +159,10 @@ const providers: Provider[] = [ BullModule.registerQueue(...bullQueues), OpenTelemetryModule.forRoot(otelConfig), ], - providers: [...providers], - exports: [...providers, BullModule], + providers: [...services, ...repositories, SchedulerRegistry], + exports: [...services, ...repositories, BullModule, SchedulerRegistry], }) -export class InfraModule {} +export class AppModule {} @Global() @Module({ @@ -121,7 +173,7 @@ export class InfraModule {} TypeOrmModule.forFeature(databaseEntities), ScheduleModule, ], - providers: [...providers], - exports: [...providers], + providers: [...services, ...repositories, SchedulerRegistry], + exports: [...services, ...repositories, SchedulerRegistry], }) -export class InfraTestModule {} +export class AppTestModule {} diff --git a/server/src/apps/immich-admin.module.ts b/server/src/apps/immich-admin.module.ts index d0e5cab4cf..eff2e9cc0c 100644 --- a/server/src/apps/immich-admin.module.ts +++ b/server/src/apps/immich-admin.module.ts @@ -1,13 +1,12 @@ import { Module } from '@nestjs/common'; +import { AppModule } from 'src/apps/app.module'; import { ListUsersCommand } from 'src/commands/list-users.command'; import { DisableOAuthLogin, EnableOAuthLogin } from 'src/commands/oauth-login'; import { DisablePasswordLoginCommand, EnablePasswordLoginCommand } from 'src/commands/password-login'; import { PromptPasswordQuestions, ResetAdminPasswordCommand } from 'src/commands/reset-admin-password.command'; -import { DomainModule } from 'src/domain/domain.module'; -import { InfraModule } from 'src/infra/infra.module'; @Module({ - imports: [InfraModule, DomainModule], + imports: [AppModule], providers: [ ResetAdminPasswordCommand, PromptPasswordQuestions, diff --git a/server/src/apps/microservices.module.ts b/server/src/apps/microservices.module.ts index 3ddfb28f3c..d9a28a91c8 100644 --- a/server/src/apps/microservices.module.ts +++ b/server/src/apps/microservices.module.ts @@ -1,10 +1,9 @@ import { Module, OnModuleInit } from '@nestjs/common'; +import { AppModule } from 'src/apps/app.module'; import { MicroservicesService } from 'src/apps/microservices.service'; -import { DomainModule } from 'src/domain/domain.module'; -import { InfraModule } from 'src/infra/infra.module'; @Module({ - imports: [InfraModule, DomainModule], + imports: [AppModule], providers: [MicroservicesService], }) export class MicroservicesModule implements OnModuleInit { diff --git a/server/src/domain/domain.module.ts b/server/src/domain/domain.module.ts deleted file mode 100644 index 04d7c51f44..0000000000 --- a/server/src/domain/domain.module.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { Global, Module, Provider } from '@nestjs/common'; -import { ActivityService } from 'src/domain/activity/activity.service'; -import { AlbumService } from 'src/domain/album/album.service'; -import { APIKeyService } from 'src/domain/api-key/api-key.service'; -import { AssetService } from 'src/domain/asset/asset.service'; -import { AuditService } from 'src/domain/audit/audit.service'; -import { AuthService } from 'src/domain/auth/auth.service'; -import { DatabaseService } from 'src/domain/database/database.service'; -import { DownloadService } from 'src/domain/download/download.service'; -import { JobService } from 'src/domain/job/job.service'; -import { LibraryService } from 'src/domain/library/library.service'; -import { MediaService } from 'src/domain/media/media.service'; -import { MetadataService } from 'src/domain/metadata/metadata.service'; -import { PartnerService } from 'src/domain/partner/partner.service'; -import { PersonService } from 'src/domain/person/person.service'; -import { SearchService } from 'src/domain/search/search.service'; -import { ServerInfoService } from 'src/domain/server-info/server-info.service'; -import { SharedLinkService } from 'src/domain/shared-link/shared-link.service'; -import { SmartInfoService } from 'src/domain/smart-info/smart-info.service'; -import { StorageTemplateService } from 'src/domain/storage-template/storage-template.service'; -import { StorageService } from 'src/domain/storage/storage.service'; -import { SystemConfigService } from 'src/domain/system-config/system-config.service'; -import { TagService } from 'src/domain/tag/tag.service'; -import { TrashService } from 'src/domain/trash/trash.service'; -import { UserService } from 'src/domain/user/user.service'; -import { ImmichLogger } from 'src/infra/logger'; - -const providers: Provider[] = [ - APIKeyService, - ActivityService, - AlbumService, - AssetService, - AuditService, - AuthService, - DatabaseService, - DownloadService, - ImmichLogger, - JobService, - LibraryService, - MediaService, - MetadataService, - PartnerService, - PersonService, - SearchService, - ServerInfoService, - SharedLinkService, - SmartInfoService, - StorageService, - StorageTemplateService, - SystemConfigService, - TagService, - TrashService, - UserService, -]; - -@Global() -@Module({ - imports: [], - providers: [...providers], - exports: [...providers], -}) -export class DomainModule {} diff --git a/server/test/utils.ts b/server/test/utils.ts index 777a6a00c1..f44f6fe17d 100644 --- a/server/test/utils.ts +++ b/server/test/utils.ts @@ -8,10 +8,10 @@ import { EventEmitter } from 'node:stream'; import { Server } from 'node:tls'; import { ApiModule } from 'src/apps/api.module'; import { ApiService } from 'src/apps/api.service'; +import { AppModule, AppTestModule } from 'src/apps/app.module'; import { MicroservicesService } from 'src/apps/microservices.service'; import { QueueName } from 'src/domain/job/job.constants'; import { dataSource } from 'src/infra/database.config'; -import { InfraModule, InfraTestModule } from 'src/infra/infra.module'; import { IJobRepository, JobItem, JobItemHandler } from 'src/interfaces/job.repository'; import { IMediaRepository } from 'src/interfaces/media.repository'; import { StorageEventType } from 'src/interfaces/storage.repository'; @@ -109,8 +109,8 @@ export const testApp = { imports: [ApiModule], providers: [ApiService, MicroservicesService], }) - .overrideModule(InfraModule) - .useModule(InfraTestModule) + .overrideModule(AppModule) + .useModule(AppTestModule) .overrideProvider(IJobRepository) .useClass(JobMock) .overrideProvider(IMediaRepository)