2023-01-21 17:11:55 +01:00
|
|
|
import {
|
|
|
|
ICryptoRepository,
|
|
|
|
IJobRepository,
|
|
|
|
IKeyRepository,
|
|
|
|
ISystemConfigRepository,
|
|
|
|
IUserRepository,
|
|
|
|
QueueName,
|
|
|
|
} from '@app/domain';
|
2023-01-24 05:13:42 +01:00
|
|
|
import { databaseConfig, UserEntity } from './db';
|
2023-01-21 17:11:55 +01:00
|
|
|
import { BullModule } from '@nestjs/bull';
|
2023-01-12 03:34:36 +01:00
|
|
|
import { Global, Module, Provider } from '@nestjs/common';
|
2023-01-24 05:13:42 +01:00
|
|
|
import { JwtModule } from '@nestjs/jwt';
|
2023-01-12 03:34:36 +01:00
|
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
2023-01-24 05:13:42 +01:00
|
|
|
import { jwtConfig } from '@app/domain';
|
|
|
|
import { CryptoRepository } from './auth/crypto.repository';
|
2023-01-21 17:11:55 +01:00
|
|
|
import { APIKeyEntity, SystemConfigEntity, UserRepository } from './db';
|
2023-01-18 15:40:15 +01:00
|
|
|
import { APIKeyRepository } from './db/repository';
|
2023-01-21 17:11:55 +01:00
|
|
|
import { SystemConfigRepository } from './db/repository/system-config.repository';
|
|
|
|
import { JobRepository } from './job';
|
2023-01-12 03:34:36 +01:00
|
|
|
|
|
|
|
const providers: Provider[] = [
|
2023-01-24 05:13:42 +01:00
|
|
|
{ provide: ICryptoRepository, useClass: CryptoRepository },
|
2023-01-18 15:40:15 +01:00
|
|
|
{ provide: IKeyRepository, useClass: APIKeyRepository },
|
2023-01-21 17:11:55 +01:00
|
|
|
{ provide: IJobRepository, useClass: JobRepository },
|
|
|
|
{ provide: ISystemConfigRepository, useClass: SystemConfigRepository },
|
2023-01-12 03:34:36 +01:00
|
|
|
{ provide: IUserRepository, useClass: UserRepository },
|
|
|
|
];
|
|
|
|
|
|
|
|
@Global()
|
|
|
|
@Module({
|
|
|
|
imports: [
|
2023-01-24 05:13:42 +01:00
|
|
|
JwtModule.register(jwtConfig),
|
2023-01-12 03:34:36 +01:00
|
|
|
TypeOrmModule.forRoot(databaseConfig),
|
2023-01-21 17:11:55 +01:00
|
|
|
TypeOrmModule.forFeature([APIKeyEntity, UserEntity, SystemConfigEntity]),
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
BullModule.registerQueue(
|
|
|
|
{ name: QueueName.USER_DELETION },
|
|
|
|
{ name: QueueName.THUMBNAIL_GENERATION },
|
|
|
|
{ name: QueueName.ASSET_UPLOADED },
|
|
|
|
{ name: QueueName.METADATA_EXTRACTION },
|
|
|
|
{ name: QueueName.VIDEO_CONVERSION },
|
|
|
|
{ name: QueueName.CHECKSUM_GENERATION },
|
|
|
|
{ name: QueueName.MACHINE_LEARNING },
|
|
|
|
{ name: QueueName.CONFIG },
|
|
|
|
{ name: QueueName.BACKGROUND_TASK },
|
|
|
|
),
|
2023-01-12 03:34:36 +01:00
|
|
|
],
|
|
|
|
providers: [...providers],
|
2023-01-24 05:13:42 +01:00
|
|
|
exports: [...providers, BullModule, JwtModule],
|
2023-01-12 03:34:36 +01:00
|
|
|
})
|
|
|
|
export class InfraModule {}
|