From 50aa3613215617da8e1e0266f7b5d3e01ea86706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renan=20Galv=C3=A3o?= Date: Sat, 20 Apr 2024 12:15:20 -0300 Subject: [PATCH] chore: added REDIS env vars refactor: BullModule injecting config from configuration.ts --- .env.dev | 3 +++ .env.dev.example | 3 +++ prisma/seed.js | 2 +- src/app.module.ts | 10 +++++----- src/config/configuration.ts | 5 +++++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.env.dev b/.env.dev index 07dcbbd..1dd2b14 100644 --- a/.env.dev +++ b/.env.dev @@ -10,3 +10,6 @@ MAIL_PASSWORD=QXzdjzWURMU3x1USFB MAIL_FROM="Therese Koch " DATABASE_URL="postgresql://project:project@localhost:5432/project?schema=public" + +REDIS_HOST=localhost +REDIS_PORT=6379 diff --git a/.env.dev.example b/.env.dev.example index 1fd8b3a..a6df51f 100644 --- a/.env.dev.example +++ b/.env.dev.example @@ -12,3 +12,6 @@ MAIL_PORT=587 MAIL_USER=camylle.rau@ethereal.email MAIL_PASSWORD=7rXNZtDR4Yq1seGBxg MAIL_FROM="Camylle Rau " + +REDIS_HOST=localhost +REDIS_PORT=6379 diff --git a/prisma/seed.js b/prisma/seed.js index 568f48e..33b6690 100644 --- a/prisma/seed.js +++ b/prisma/seed.js @@ -21,7 +21,7 @@ async function main() { if (env.NODE_ENV === 'development') { await development() - } else if (env.NODE_ENV === 'production') { + } else if (env.NODE_ENV === 'production' || env.NODE_ENV === 'preview') { // comment this line when first missionary field is open and real data is going to be sent // don't forget to exclude fictitious data await production() diff --git a/src/app.module.ts b/src/app.module.ts index ebcfda4..dbd6743 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -46,11 +46,11 @@ import { QueueModule } from './queue/queue.module' limit: config.get('throttle.limit'), }], }), - BullModule.forRoot({ - redis: { - host: 'localhost', - port: 6379, - }, + BullModule.forRootAsync({ + inject: [ConfigService], + useFactory: (config: ConfigService) => ({ + redis: config.get('redis') + }) }), QueueModule, diff --git a/src/config/configuration.ts b/src/config/configuration.ts index de4be6f..1624d9d 100644 --- a/src/config/configuration.ts +++ b/src/config/configuration.ts @@ -78,4 +78,9 @@ export default () => ({ log: { clearBeyondMonths: 3, }, + + redis: { + host: process.env.REDIS_HOST, + port: process.env.REDIS_PORT + } })