Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Bugfix/change environment variables redis host and port to mandatory (#1211)

Thomas Kaulcf2c5bad02c5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b23a8fd318..3a039ca7fc 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 274fe29bde..9780aa0737 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 96cf503256..c87ccaf691 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 <CacheManagerOptions>{
+ 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 48133743e5..bdd3d112bb 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: '' }),