mirror of
https://github.com/immich-app/immich.git
synced 2024-12-22 01:47:08 +02:00
refactor: infra/domain module (#8130)
This commit is contained in:
parent
907eb869bc
commit
0c13c63bb6
@ -3,6 +3,7 @@ import { APP_GUARD, APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core';
|
|||||||
import { ScheduleModule } from '@nestjs/schedule';
|
import { ScheduleModule } from '@nestjs/schedule';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
import { ApiService } from 'src/apps/api.service';
|
import { ApiService } from 'src/apps/api.service';
|
||||||
|
import { AppModule } from 'src/apps/app.module';
|
||||||
import { ActivityController } from 'src/controllers/activity.controller';
|
import { ActivityController } from 'src/controllers/activity.controller';
|
||||||
import { AlbumController } from 'src/controllers/album.controller';
|
import { AlbumController } from 'src/controllers/album.controller';
|
||||||
import { APIKeyController } from 'src/controllers/api-key.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 { TagController } from 'src/controllers/tag.controller';
|
||||||
import { TrashController } from 'src/controllers/trash.controller';
|
import { TrashController } from 'src/controllers/trash.controller';
|
||||||
import { UserController } from 'src/controllers/user.controller';
|
import { UserController } from 'src/controllers/user.controller';
|
||||||
import { DomainModule } from 'src/domain/domain.module';
|
|
||||||
import { AssetEntity } from 'src/entities/asset.entity';
|
import { AssetEntity } from 'src/entities/asset.entity';
|
||||||
import { ExifEntity } from 'src/entities/exif.entity';
|
import { ExifEntity } from 'src/entities/exif.entity';
|
||||||
import { AssetRepositoryV1, IAssetRepositoryV1 } from 'src/immich/api-v1/asset/asset-repository';
|
import { AssetRepositoryV1, IAssetRepositoryV1 } from 'src/immich/api-v1/asset/asset-repository';
|
||||||
import { AssetController as AssetControllerV1 } from 'src/immich/api-v1/asset/asset.controller';
|
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 { 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 { AuthGuard } from 'src/middleware/auth.guard';
|
||||||
import { ErrorInterceptor } from 'src/middleware/error.interceptor';
|
import { ErrorInterceptor } from 'src/middleware/error.interceptor';
|
||||||
import { FileUploadInterceptor } from 'src/middleware/file-upload.interceptor';
|
import { FileUploadInterceptor } from 'src/middleware/file-upload.interceptor';
|
||||||
@ -38,8 +37,7 @@ import { FileUploadInterceptor } from 'src/middleware/file-upload.interceptor';
|
|||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
//
|
//
|
||||||
InfraModule,
|
AppModule,
|
||||||
DomainModule,
|
|
||||||
ScheduleModule.forRoot(),
|
ScheduleModule.forRoot(),
|
||||||
TypeOrmModule.forFeature([AssetEntity, ExifEntity]),
|
TypeOrmModule.forFeature([AssetEntity, ExifEntity]),
|
||||||
],
|
],
|
||||||
|
@ -6,9 +6,34 @@ import { ScheduleModule, SchedulerRegistry } from '@nestjs/schedule';
|
|||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
import { OpenTelemetryModule } from 'nestjs-otel';
|
import { OpenTelemetryModule } from 'nestjs-otel';
|
||||||
import { bullConfig, bullQueues, immichAppConfig } from 'src/config';
|
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 { databaseEntities } from 'src/entities';
|
||||||
import { databaseConfig } from 'src/infra/database.config';
|
import { databaseConfig } from 'src/infra/database.config';
|
||||||
import { otelConfig } from 'src/infra/instrumentation';
|
import { otelConfig } from 'src/infra/instrumentation';
|
||||||
|
import { ImmichLogger } from 'src/infra/logger';
|
||||||
import { IAccessRepository } from 'src/interfaces/access.repository';
|
import { IAccessRepository } from 'src/interfaces/access.repository';
|
||||||
import { IActivityRepository } from 'src/interfaces/activity.repository';
|
import { IActivityRepository } from 'src/interfaces/activity.repository';
|
||||||
import { IAlbumRepository } from 'src/interfaces/album.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 { UserTokenRepository } from 'src/repositories/user-token.repository';
|
||||||
import { UserRepository } from 'src/repositories/user.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: IActivityRepository, useClass: ActivityRepository },
|
||||||
{ provide: IAccessRepository, useClass: AccessRepository },
|
{ provide: IAccessRepository, useClass: AccessRepository },
|
||||||
{ provide: IAlbumRepository, useClass: AlbumRepository },
|
{ provide: IAlbumRepository, useClass: AlbumRepository },
|
||||||
@ -92,7 +145,6 @@ const providers: Provider[] = [
|
|||||||
{ provide: IMediaRepository, useClass: MediaRepository },
|
{ provide: IMediaRepository, useClass: MediaRepository },
|
||||||
{ provide: IUserRepository, useClass: UserRepository },
|
{ provide: IUserRepository, useClass: UserRepository },
|
||||||
{ provide: IUserTokenRepository, useClass: UserTokenRepository },
|
{ provide: IUserTokenRepository, useClass: UserTokenRepository },
|
||||||
SchedulerRegistry,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
@Global()
|
@Global()
|
||||||
@ -107,10 +159,10 @@ const providers: Provider[] = [
|
|||||||
BullModule.registerQueue(...bullQueues),
|
BullModule.registerQueue(...bullQueues),
|
||||||
OpenTelemetryModule.forRoot(otelConfig),
|
OpenTelemetryModule.forRoot(otelConfig),
|
||||||
],
|
],
|
||||||
providers: [...providers],
|
providers: [...services, ...repositories, SchedulerRegistry],
|
||||||
exports: [...providers, BullModule],
|
exports: [...services, ...repositories, BullModule, SchedulerRegistry],
|
||||||
})
|
})
|
||||||
export class InfraModule {}
|
export class AppModule {}
|
||||||
|
|
||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
@ -121,7 +173,7 @@ export class InfraModule {}
|
|||||||
TypeOrmModule.forFeature(databaseEntities),
|
TypeOrmModule.forFeature(databaseEntities),
|
||||||
ScheduleModule,
|
ScheduleModule,
|
||||||
],
|
],
|
||||||
providers: [...providers],
|
providers: [...services, ...repositories, SchedulerRegistry],
|
||||||
exports: [...providers],
|
exports: [...services, ...repositories, SchedulerRegistry],
|
||||||
})
|
})
|
||||||
export class InfraTestModule {}
|
export class AppTestModule {}
|
@ -1,13 +1,12 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
import { AppModule } from 'src/apps/app.module';
|
||||||
import { ListUsersCommand } from 'src/commands/list-users.command';
|
import { ListUsersCommand } from 'src/commands/list-users.command';
|
||||||
import { DisableOAuthLogin, EnableOAuthLogin } from 'src/commands/oauth-login';
|
import { DisableOAuthLogin, EnableOAuthLogin } from 'src/commands/oauth-login';
|
||||||
import { DisablePasswordLoginCommand, EnablePasswordLoginCommand } from 'src/commands/password-login';
|
import { DisablePasswordLoginCommand, EnablePasswordLoginCommand } from 'src/commands/password-login';
|
||||||
import { PromptPasswordQuestions, ResetAdminPasswordCommand } from 'src/commands/reset-admin-password.command';
|
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({
|
@Module({
|
||||||
imports: [InfraModule, DomainModule],
|
imports: [AppModule],
|
||||||
providers: [
|
providers: [
|
||||||
ResetAdminPasswordCommand,
|
ResetAdminPasswordCommand,
|
||||||
PromptPasswordQuestions,
|
PromptPasswordQuestions,
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import { Module, OnModuleInit } from '@nestjs/common';
|
import { Module, OnModuleInit } from '@nestjs/common';
|
||||||
|
import { AppModule } from 'src/apps/app.module';
|
||||||
import { MicroservicesService } from 'src/apps/microservices.service';
|
import { MicroservicesService } from 'src/apps/microservices.service';
|
||||||
import { DomainModule } from 'src/domain/domain.module';
|
|
||||||
import { InfraModule } from 'src/infra/infra.module';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [InfraModule, DomainModule],
|
imports: [AppModule],
|
||||||
providers: [MicroservicesService],
|
providers: [MicroservicesService],
|
||||||
})
|
})
|
||||||
export class MicroservicesModule implements OnModuleInit {
|
export class MicroservicesModule implements OnModuleInit {
|
||||||
|
@ -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 {}
|
|
@ -8,10 +8,10 @@ import { EventEmitter } from 'node:stream';
|
|||||||
import { Server } from 'node:tls';
|
import { Server } from 'node:tls';
|
||||||
import { ApiModule } from 'src/apps/api.module';
|
import { ApiModule } from 'src/apps/api.module';
|
||||||
import { ApiService } from 'src/apps/api.service';
|
import { ApiService } from 'src/apps/api.service';
|
||||||
|
import { AppModule, AppTestModule } from 'src/apps/app.module';
|
||||||
import { MicroservicesService } from 'src/apps/microservices.service';
|
import { MicroservicesService } from 'src/apps/microservices.service';
|
||||||
import { QueueName } from 'src/domain/job/job.constants';
|
import { QueueName } from 'src/domain/job/job.constants';
|
||||||
import { dataSource } from 'src/infra/database.config';
|
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 { IJobRepository, JobItem, JobItemHandler } from 'src/interfaces/job.repository';
|
||||||
import { IMediaRepository } from 'src/interfaces/media.repository';
|
import { IMediaRepository } from 'src/interfaces/media.repository';
|
||||||
import { StorageEventType } from 'src/interfaces/storage.repository';
|
import { StorageEventType } from 'src/interfaces/storage.repository';
|
||||||
@ -109,8 +109,8 @@ export const testApp = {
|
|||||||
imports: [ApiModule],
|
imports: [ApiModule],
|
||||||
providers: [ApiService, MicroservicesService],
|
providers: [ApiService, MicroservicesService],
|
||||||
})
|
})
|
||||||
.overrideModule(InfraModule)
|
.overrideModule(AppModule)
|
||||||
.useModule(InfraTestModule)
|
.useModule(AppTestModule)
|
||||||
.overrideProvider(IJobRepository)
|
.overrideProvider(IJobRepository)
|
||||||
.useClass(JobMock)
|
.useClass(JobMock)
|
||||||
.overrideProvider(IMediaRepository)
|
.overrideProvider(IMediaRepository)
|
||||||
|
Loading…
Reference in New Issue
Block a user