refactor(server): domain and infra modules (#6301)
This commit is contained in:
@@ -4,11 +4,6 @@ import { QueueOptions } from 'bullmq';
|
||||
import { RedisOptions } from 'ioredis';
|
||||
|
||||
function parseRedisConfig(): RedisOptions {
|
||||
if (process.env.IMMICH_TEST_ENV == 'true') {
|
||||
// Currently running e2e tests, do not use redis
|
||||
return {};
|
||||
}
|
||||
|
||||
const redisUrl = process.env.REDIS_URL;
|
||||
if (redisUrl && redisUrl.startsWith('ioredis://')) {
|
||||
try {
|
||||
@@ -28,11 +23,9 @@ function parseRedisConfig(): RedisOptions {
|
||||
};
|
||||
}
|
||||
|
||||
export const redisConfig: RedisOptions = parseRedisConfig();
|
||||
|
||||
export const bullConfig: QueueOptions = {
|
||||
prefix: 'immich_bull',
|
||||
connection: redisConfig,
|
||||
connection: parseRedisConfig(),
|
||||
defaultJobOptions: {
|
||||
attempts: 3,
|
||||
removeOnComplete: true,
|
||||
|
||||
@@ -94,26 +94,30 @@ const providers: Provider[] = [
|
||||
SchedulerRegistry,
|
||||
];
|
||||
|
||||
const imports = [
|
||||
ConfigModule.forRoot(immichAppConfig),
|
||||
TypeOrmModule.forRoot(databaseConfig),
|
||||
TypeOrmModule.forFeature(databaseEntities),
|
||||
ScheduleModule,
|
||||
];
|
||||
|
||||
const moduleExports = [...providers];
|
||||
|
||||
if (process.env.IMMICH_TEST_ENV !== 'true') {
|
||||
// Currently not running e2e tests, set up redis and bull queues
|
||||
imports.push(BullModule.forRoot(bullConfig));
|
||||
imports.push(BullModule.registerQueue(...bullQueues));
|
||||
moduleExports.push(BullModule);
|
||||
}
|
||||
@Global()
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot(immichAppConfig),
|
||||
TypeOrmModule.forRoot(databaseConfig),
|
||||
TypeOrmModule.forFeature(databaseEntities),
|
||||
ScheduleModule,
|
||||
BullModule.forRoot(bullConfig),
|
||||
BullModule.registerQueue(...bullQueues),
|
||||
],
|
||||
providers: [...providers],
|
||||
exports: [...providers, BullModule],
|
||||
})
|
||||
export class InfraModule {}
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
imports,
|
||||
imports: [
|
||||
ConfigModule.forRoot(immichAppConfig),
|
||||
TypeOrmModule.forRoot(databaseConfig),
|
||||
TypeOrmModule.forFeature(databaseEntities),
|
||||
ScheduleModule,
|
||||
],
|
||||
providers: [...providers],
|
||||
exports: moduleExports,
|
||||
exports: [...providers],
|
||||
})
|
||||
export class InfraModule {}
|
||||
export class InfraTestModule {}
|
||||
|
||||
Reference in New Issue
Block a user