2024-09-30 17:31:21 -04:00
|
|
|
import { Inject } from '@nestjs/common';
|
|
|
|
|
import { SystemConfig } from 'src/config';
|
2024-10-01 16:03:55 -04:00
|
|
|
import { IConfigRepository } from 'src/interfaces/config.interface';
|
2024-09-30 17:31:21 -04:00
|
|
|
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
|
|
|
|
import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interface';
|
|
|
|
|
import { getConfig, updateConfig } from 'src/utils/config';
|
|
|
|
|
|
|
|
|
|
export class BaseService {
|
|
|
|
|
constructor(
|
2024-10-01 16:03:55 -04:00
|
|
|
@Inject(IConfigRepository) protected configRepository: IConfigRepository,
|
2024-09-30 17:31:21 -04:00
|
|
|
@Inject(ISystemMetadataRepository) protected systemMetadataRepository: ISystemMetadataRepository,
|
|
|
|
|
@Inject(ILoggerRepository) protected logger: ILoggerRepository,
|
|
|
|
|
) {}
|
|
|
|
|
|
2024-10-01 16:03:55 -04:00
|
|
|
private get repos() {
|
|
|
|
|
return {
|
|
|
|
|
configRepo: this.configRepository,
|
|
|
|
|
metadataRepo: this.systemMetadataRepository,
|
|
|
|
|
logger: this.logger,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-30 17:31:21 -04:00
|
|
|
getConfig(options: { withCache: boolean }) {
|
2024-10-01 16:03:55 -04:00
|
|
|
return getConfig(this.repos, options);
|
2024-09-30 17:31:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateConfig(newConfig: SystemConfig) {
|
2024-10-01 16:03:55 -04:00
|
|
|
return updateConfig(this.repos, newConfig);
|
2024-09-30 17:31:21 -04:00
|
|
|
}
|
|
|
|
|
}
|