Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/expose ENABLE_FEATURE_CRON environment variable (#7090)
Thomas Kaul1896289bc9b4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d5dd293bb6..41bf233c0d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## Unreleased+### Added++- Exposed the `ENABLE_FEATURE_CRON` environment variable to control scheduled cron job execution+### Changed- Improved the language localization for German (`de`)diff --git a/apps/api/src/services/configuration/configuration.service.ts b/apps/api/src/services/configuration/configuration.service.tsindex 5f9d1055d1..328620164c 100644--- a/apps/api/src/services/configuration/configuration.service.ts+++ b/apps/api/src/services/configuration/configuration.service.ts@@ -43,6 +43,7 @@ export class ConfigurationService {ENABLE_FEATURE_AUTH_GOOGLE: bool({ default: false }),ENABLE_FEATURE_AUTH_OIDC: bool({ default: false }),ENABLE_FEATURE_AUTH_TOKEN: bool({ default: true }),+ ENABLE_FEATURE_CRON: bool({ default: true }),ENABLE_FEATURE_FEAR_AND_GREED_INDEX: bool({ default: false }),ENABLE_FEATURE_GATHER_NEW_EXCHANGE_RATES: bool({ default: true }),ENABLE_FEATURE_READ_ONLY_MODE: bool({ default: false }),diff --git a/apps/api/src/services/cron/cron.module.ts b/apps/api/src/services/cron/cron.module.tsindex bcc9d3360b..3d999e3977 100644--- a/apps/api/src/services/cron/cron.module.ts+++ b/apps/api/src/services/cron/cron.module.ts@@ -1,12 +1,19 @@import { UserModule } from '@ghostfolio/api/app/user/user.module';+import { UserService } from '@ghostfolio/api/app/user/user.service';import { ConfigurationModule } from '@ghostfolio/api/services/configuration/configuration.module';+import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service';import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.module';+import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service';import { PropertyModule } from '@ghostfolio/api/services/property/property.module';+import { PropertyService } from '@ghostfolio/api/services/property/property.service';import { DataGatheringQueueModule } from '@ghostfolio/api/services/queues/data-gathering/data-gathering.module';+import { DataGatheringService } from '@ghostfolio/api/services/queues/data-gathering/data-gathering.service';import { StatisticsGatheringQueueModule } from '@ghostfolio/api/services/queues/statistics-gathering/statistics-gathering.module';+import { StatisticsGatheringService } from '@ghostfolio/api/services/queues/statistics-gathering/statistics-gathering.service';import { TwitterBotModule } from '@ghostfolio/api/services/twitter-bot/twitter-bot.module';+import { TwitterBotService } from '@ghostfolio/api/services/twitter-bot/twitter-bot.service';-import { Module } from '@nestjs/common';+import { Logger, Module } from '@nestjs/common';import { CronService } from './cron.service';@@ -20,6 +27,44 @@ import { CronService } from './cron.service';TwitterBotModule,UserModule],- providers: [CronService]+ providers: [+ {+ inject: [+ ConfigurationService,+ DataGatheringService,+ ExchangeRateDataService,+ PropertyService,+ StatisticsGatheringService,+ TwitterBotService,+ UserService+ ],+ provide: CronService,+ useFactory: (+ configurationService: ConfigurationService,+ dataGatheringService: DataGatheringService,+ exchangeRateDataService: ExchangeRateDataService,+ propertyService: PropertyService,+ statisticsGatheringService: StatisticsGatheringService,+ twitterBotService: TwitterBotService,+ userService: UserService+ ) => {+ if (!configurationService.get('ENABLE_FEATURE_CRON')) {+ Logger.log('Scheduled cron jobs are disabled', 'CronService');++ return null;+ }++ return new CronService(+ configurationService,+ dataGatheringService,+ exchangeRateDataService,+ propertyService,+ statisticsGatheringService,+ twitterBotService,+ userService+ );+ }+ }+ ]})export class CronModule {}diff --git a/apps/api/src/services/interfaces/environment.interface.ts b/apps/api/src/services/interfaces/environment.interface.tsindex 57c58898e0..45654a2e3a 100644--- a/apps/api/src/services/interfaces/environment.interface.ts+++ b/apps/api/src/services/interfaces/environment.interface.ts@@ -19,6 +19,7 @@ export interface Environment extends CleanedEnvAccessors {ENABLE_FEATURE_AUTH_GOOGLE: boolean;ENABLE_FEATURE_AUTH_OIDC: boolean;ENABLE_FEATURE_AUTH_TOKEN: boolean;+ ENABLE_FEATURE_CRON: boolean;ENABLE_FEATURE_FEAR_AND_GREED_INDEX: boolean;ENABLE_FEATURE_GATHER_NEW_EXCHANGE_RATES: boolean;ENABLE_FEATURE_READ_ONLY_MODE: boolean;