refactor(server): system config (#1353)

* refactor(server): system config

* fix: jest circular import

* chore: ignore migrations in coverage report

* chore: tests

* chore: tests

* chore: todo note

* chore: remove vite config backup

* chore: fix redis hostname
This commit is contained in:
Jason Rasmussen 2023-01-21 11:11:55 -05:00 committed by GitHub
parent 66cd7dd809
commit c0a6b3d5a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
92 changed files with 842 additions and 614 deletions

View file

@ -1,6 +1,6 @@
import { APP_UPLOAD_LOCATION } from '@app/common';
import { AssetEntity, AssetType, SystemConfig } from '@app/infra';
import { ImmichConfigService, INITIAL_SYSTEM_CONFIG } from '@app/immich-config';
import { SystemConfigService, INITIAL_SYSTEM_CONFIG } from '@app/domain';
import { Inject, Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import fsPromise from 'fs/promises';
@ -19,7 +19,7 @@ import {
supportedMonthTokens,
supportedSecondTokens,
supportedYearTokens,
} from './constants/supported-datetime-template';
} from '@app/domain';
const moveFile = promisify<string, string, mv.Options>(mv);
@ -32,14 +32,14 @@ export class StorageService {
constructor(
@InjectRepository(AssetEntity)
private assetRepository: Repository<AssetEntity>,
private immichConfigService: ImmichConfigService,
private systemConfigService: SystemConfigService,
@Inject(INITIAL_SYSTEM_CONFIG) config: SystemConfig,
) {
this.storageTemplate = this.compile(config.storageTemplate.template);
this.immichConfigService.addValidator((config) => this.validateConfig(config));
this.systemConfigService.addValidator((config) => this.validateConfig(config));
this.immichConfigService.config$.subscribe((config) => {
this.systemConfigService.config$.subscribe((config) => {
this.logger.debug(`Received new config, recompiling storage template: ${config.storageTemplate.template}`);
this.storageTemplate = this.compile(config.storageTemplate.template);
});