Skip to content

Commit 1e957be

Browse files
committed
fix(rabbitmq): get RABBITMQ_URL from ConfigService
1 parent bb4adb3 commit 1e957be

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/submissions/submissions.module.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { RabbitMQModule } from '@golevelup/nestjs-rabbitmq';
22
import { CacheModule, forwardRef, Module } from '@nestjs/common';
3+
import { ConfigModule, ConfigService } from '@nestjs/config';
34
import { TypeOrmModule } from '@nestjs/typeorm';
45
import { UsersModule } from 'src/users/users.module';
56
import { BenchmarkModule } from '../benchmarks/benchmark.module';
@@ -12,14 +13,20 @@ import { SubmissionsService } from './submissions.service';
1213
TypeOrmModule.forFeature([Submission]),
1314
forwardRef(() => UsersModule),
1415
CacheModule.register(),
15-
RabbitMQModule.forRoot(RabbitMQModule, {
16-
exchanges: [
17-
{
18-
name: 'jobs_ex',
19-
type: 'direct',
20-
},
21-
],
22-
uri: process.env.RABBITMQ_URL || 'amqp://admin:admin@localhost:5672/',
16+
RabbitMQModule.forRootAsync(RabbitMQModule, {
17+
imports: [ConfigModule],
18+
inject: [ConfigService],
19+
useFactory: async (configService: ConfigService) => ({
20+
exchanges: [
21+
{
22+
name: 'jobs_ex',
23+
type: 'direct',
24+
},
25+
],
26+
uri:
27+
configService.get<string>('RABBITMQ_URL') ||
28+
'amqp://admin:admin@localhost:5672/',
29+
}),
2330
}),
2431
forwardRef(() => BenchmarkModule),
2532
],

0 commit comments

Comments
 (0)