2023-01-21 17:11:55 +01:00
|
|
|
import {
|
2023-02-25 15:12:03 +01:00
|
|
|
IAlbumRepository,
|
|
|
|
IAssetRepository,
|
|
|
|
ICommunicationRepository,
|
2023-01-21 17:11:55 +01:00
|
|
|
ICryptoRepository,
|
2023-02-01 21:55:06 +01:00
|
|
|
IDeviceInfoRepository,
|
2023-01-21 17:11:55 +01:00
|
|
|
IJobRepository,
|
|
|
|
IKeyRepository,
|
2023-02-25 15:12:03 +01:00
|
|
|
IMachineLearningRepository,
|
|
|
|
IMediaRepository,
|
2023-03-03 03:47:08 +01:00
|
|
|
ISearchRepository,
|
2023-01-25 17:35:28 +01:00
|
|
|
ISharedLinkRepository,
|
2023-02-25 15:12:03 +01:00
|
|
|
ISmartInfoRepository,
|
2023-02-03 16:16:25 +01:00
|
|
|
IStorageRepository,
|
2023-01-21 17:11:55 +01:00
|
|
|
ISystemConfigRepository,
|
|
|
|
IUserRepository,
|
2023-02-25 15:12:03 +01:00
|
|
|
IUserTokenRepository,
|
2023-01-21 17:11:55 +01:00
|
|
|
QueueName,
|
|
|
|
} from '@app/domain';
|
|
|
|
import { BullModule } from '@nestjs/bull';
|
2023-01-12 03:34:36 +01:00
|
|
|
import { Global, Module, Provider } from '@nestjs/common';
|
|
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
2023-01-24 05:13:42 +01:00
|
|
|
import { CryptoRepository } from './auth/crypto.repository';
|
2023-02-25 15:12:03 +01:00
|
|
|
import { CommunicationGateway, CommunicationRepository } from './communication';
|
2023-02-01 21:55:06 +01:00
|
|
|
import {
|
2023-02-25 15:12:03 +01:00
|
|
|
AlbumEntity,
|
|
|
|
AlbumRepository,
|
2023-02-01 21:55:06 +01:00
|
|
|
APIKeyEntity,
|
|
|
|
APIKeyRepository,
|
2023-02-25 15:12:03 +01:00
|
|
|
AssetEntity,
|
|
|
|
AssetRepository,
|
2023-02-01 21:55:06 +01:00
|
|
|
databaseConfig,
|
|
|
|
DeviceInfoEntity,
|
|
|
|
DeviceInfoRepository,
|
|
|
|
SharedLinkEntity,
|
|
|
|
SharedLinkRepository,
|
2023-02-25 15:12:03 +01:00
|
|
|
SmartInfoEntity,
|
|
|
|
SmartInfoRepository,
|
2023-02-01 21:55:06 +01:00
|
|
|
SystemConfigEntity,
|
|
|
|
SystemConfigRepository,
|
|
|
|
UserEntity,
|
|
|
|
UserRepository,
|
|
|
|
UserTokenEntity,
|
2023-02-25 15:12:03 +01:00
|
|
|
UserTokenRepository,
|
2023-02-01 21:55:06 +01:00
|
|
|
} from './db';
|
2023-01-21 17:11:55 +01:00
|
|
|
import { JobRepository } from './job';
|
2023-02-25 15:12:03 +01:00
|
|
|
import { MachineLearningRepository } from './machine-learning';
|
|
|
|
import { MediaRepository } from './media';
|
2023-03-03 03:47:08 +01:00
|
|
|
import { TypesenseRepository } from './search';
|
2023-02-03 16:16:25 +01:00
|
|
|
import { FilesystemProvider } from './storage';
|
2023-01-12 03:34:36 +01:00
|
|
|
|
|
|
|
const providers: Provider[] = [
|
2023-02-25 15:12:03 +01:00
|
|
|
{ provide: IAlbumRepository, useClass: AlbumRepository },
|
|
|
|
{ provide: IAssetRepository, useClass: AssetRepository },
|
|
|
|
{ provide: ICommunicationRepository, useClass: CommunicationRepository },
|
|
|
|
{ provide: ICryptoRepository, useClass: CryptoRepository },
|
2023-02-01 21:55:06 +01:00
|
|
|
{ provide: IDeviceInfoRepository, useClass: DeviceInfoRepository },
|
2023-01-18 15:40:15 +01:00
|
|
|
{ provide: IKeyRepository, useClass: APIKeyRepository },
|
2023-01-21 17:11:55 +01:00
|
|
|
{ provide: IJobRepository, useClass: JobRepository },
|
2023-02-25 15:12:03 +01:00
|
|
|
{ provide: IMachineLearningRepository, useClass: MachineLearningRepository },
|
|
|
|
{ provide: IMediaRepository, useClass: MediaRepository },
|
2023-03-03 03:47:08 +01:00
|
|
|
{ provide: ISearchRepository, useClass: TypesenseRepository },
|
2023-01-25 17:35:28 +01:00
|
|
|
{ provide: ISharedLinkRepository, useClass: SharedLinkRepository },
|
2023-02-25 15:12:03 +01:00
|
|
|
{ provide: ISmartInfoRepository, useClass: SmartInfoRepository },
|
2023-02-03 16:16:25 +01:00
|
|
|
{ provide: IStorageRepository, useClass: FilesystemProvider },
|
2023-01-21 17:11:55 +01:00
|
|
|
{ provide: ISystemConfigRepository, useClass: SystemConfigRepository },
|
2023-01-12 03:34:36 +01:00
|
|
|
{ provide: IUserRepository, useClass: UserRepository },
|
2023-01-27 21:50:07 +01:00
|
|
|
{ provide: IUserTokenRepository, useClass: UserTokenRepository },
|
2023-01-12 03:34:36 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
@Global()
|
|
|
|
@Module({
|
|
|
|
imports: [
|
|
|
|
TypeOrmModule.forRoot(databaseConfig),
|
2023-02-01 21:55:06 +01:00
|
|
|
TypeOrmModule.forFeature([
|
2023-02-25 15:12:03 +01:00
|
|
|
AssetEntity,
|
|
|
|
AlbumEntity,
|
2023-02-01 21:55:06 +01:00
|
|
|
APIKeyEntity,
|
|
|
|
DeviceInfoEntity,
|
|
|
|
UserEntity,
|
|
|
|
SharedLinkEntity,
|
2023-02-25 15:12:03 +01:00
|
|
|
SmartInfoEntity,
|
2023-02-01 21:55:06 +01:00
|
|
|
SystemConfigEntity,
|
|
|
|
UserTokenEntity,
|
|
|
|
]),
|
2023-01-21 17:11:55 +01:00
|
|
|
BullModule.forRootAsync({
|
|
|
|
useFactory: async () => ({
|
|
|
|
prefix: 'immich_bull',
|
|
|
|
redis: {
|
|
|
|
host: process.env.REDIS_HOSTNAME || 'immich_redis',
|
|
|
|
port: parseInt(process.env.REDIS_PORT || '6379'),
|
|
|
|
db: parseInt(process.env.REDIS_DBINDEX || '0'),
|
|
|
|
password: process.env.REDIS_PASSWORD || undefined,
|
|
|
|
path: process.env.REDIS_SOCKET || undefined,
|
|
|
|
},
|
|
|
|
defaultJobOptions: {
|
|
|
|
attempts: 3,
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: false,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
}),
|
2023-02-25 15:12:03 +01:00
|
|
|
BullModule.registerQueue(...Object.values(QueueName).map((name) => ({ name }))),
|
2023-01-12 03:34:36 +01:00
|
|
|
],
|
2023-02-25 15:12:03 +01:00
|
|
|
providers: [...providers, CommunicationGateway],
|
2023-01-27 21:50:07 +01:00
|
|
|
exports: [...providers, BullModule],
|
2023-01-12 03:34:36 +01:00
|
|
|
})
|
|
|
|
export class InfraModule {}
|