From cf2c5bad02c5fd6c45df06dc3ce9f3eab3c2ac68 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:35:37 +0200 Subject: [PATCH] Bugfix/change environment variables redis host and port to mandatory (#1211) * Change REDIS_HOST and REDIS_PORT to mandatory * Update changelog --- CHANGELOG.md | 6 +++++ README.md | 4 ++-- .../src/app/redis-cache/redis-cache.module.ts | 22 +++++++++---------- .../api/src/services/configuration.service.ts | 4 ++-- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b23a8fd31..3a039ca7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Made the environment variables `REDIS_HOST` and `REDIS_PORT` mandatory + ## 1.185.0 - 30.08.2022 ### Added diff --git a/README.md b/README.md index 274fe29bd..9780aa073 100644 --- a/README.md +++ b/README.md @@ -92,9 +92,9 @@ The frontend is built with [Angular](https://angular.io) and uses [Angular Mater | `POSTGRES_DB` | | The name of the _PostgreSQL_ database | | `POSTGRES_PASSWORD` | | The password of the _PostgreSQL_ database | | `POSTGRES_USER` | | The user of the _PostgreSQL_ database | -| `REDIS_HOST` | `localhost` | The host where _Redis_ is running | +| `REDIS_HOST` | | The host where _Redis_ is running | | `REDIS_PASSWORD` | | The password of _Redis_ | -| `REDIS_PORT` | `6379` | The port where _Redis_ is running | +| `REDIS_PORT` | | The port where _Redis_ is running | ### Run with Docker Compose diff --git a/apps/api/src/app/redis-cache/redis-cache.module.ts b/apps/api/src/app/redis-cache/redis-cache.module.ts index 96cf50325..c87ccaf69 100644 --- a/apps/api/src/app/redis-cache/redis-cache.module.ts +++ b/apps/api/src/app/redis-cache/redis-cache.module.ts @@ -1,7 +1,6 @@ import { ConfigurationModule } from '@ghostfolio/api/services/configuration.module'; import { ConfigurationService } from '@ghostfolio/api/services/configuration.service'; -import { CacheModule, Module } from '@nestjs/common'; -import { ConfigModule, ConfigService } from '@nestjs/config'; +import { CacheManagerOptions, CacheModule, Module } from '@nestjs/common'; import * as redisStore from 'cache-manager-redis-store'; import { RedisCacheService } from './redis-cache.service'; @@ -9,16 +8,15 @@ import { RedisCacheService } from './redis-cache.service'; @Module({ imports: [ CacheModule.registerAsync({ - imports: [ConfigModule], - inject: [ConfigService], - useFactory: async (configurationService: ConfigurationService) => ({ - host: configurationService.get('REDIS_HOST'), - max: configurationService.get('MAX_ITEM_IN_CACHE'), - password: configurationService.get('REDIS_PASSWORD'), - port: configurationService.get('REDIS_PORT'), - store: redisStore, - ttl: configurationService.get('CACHE_TTL') - }) + imports: [ConfigurationModule], + inject: [ConfigurationService], + useFactory: async (configurationService: ConfigurationService) => { + return { + max: configurationService.get('MAX_ITEM_IN_CACHE'), + store: redisStore, + ttl: configurationService.get('CACHE_TTL') + }; + } }), ConfigurationModule ], diff --git a/apps/api/src/services/configuration.service.ts b/apps/api/src/services/configuration.service.ts index 48133743e..bdd3d112b 100644 --- a/apps/api/src/services/configuration.service.ts +++ b/apps/api/src/services/configuration.service.ts @@ -39,9 +39,9 @@ export class ConfigurationService { MAX_ITEM_IN_CACHE: num({ default: 9999 }), PORT: port({ default: 3333 }), RAKUTEN_RAPID_API_KEY: str({ default: '' }), - REDIS_HOST: host({ default: 'localhost' }), + REDIS_HOST: host(), REDIS_PASSWORD: str({ default: '' }), - REDIS_PORT: port({ default: 6379 }), + REDIS_PORT: port(), ROOT_URL: str({ default: 'http://localhost:4200' }), STRIPE_PUBLIC_KEY: str({ default: '' }), STRIPE_SECRET_KEY: str({ default: '' }),