Skip to content

Commit

Permalink
chore: added REDIS env vars
Browse files Browse the repository at this point in the history
refactor: BullModule injecting config from configuration.ts
  • Loading branch information
RenanGalvao committed Apr 20, 2024
1 parent 3d9fe7a commit 50aa361
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ MAIL_PASSWORD=QXzdjzWURMU3x1USFB
MAIL_FROM="Therese Koch <[email protected]>"

DATABASE_URL="postgresql://project:project@localhost:5432/project?schema=public"

REDIS_HOST=localhost
REDIS_PORT=6379
3 changes: 3 additions & 0 deletions .env.dev.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ MAIL_PORT=587
[email protected]
MAIL_PASSWORD=7rXNZtDR4Yq1seGBxg
MAIL_FROM="Camylle Rau <[email protected]>"

REDIS_HOST=localhost
REDIS_PORT=6379
2 changes: 1 addition & 1 deletion prisma/seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/config/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,9 @@ export default () => ({
log: {
clearBeyondMonths: 3,
},

redis: {
host: process.env.REDIS_HOST,
port: process.env.REDIS_PORT
}
})

0 comments on commit 50aa361

Please sign in to comment.