Skip to content

Commit

Permalink
change: Add health check to consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
mapeveri committed Mar 22, 2024
1 parent 67e56d9 commit 4a46745
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
NODE_ENV=development
SERVER_PORT=4000
SERVER_CONSUMER_PORT=4001
POSTGRES_USER=postgres
POSTGRES_PASSWORD=app123456
POSTGRES_DATABASE=languages
Expand Down
12 changes: 10 additions & 2 deletions src/consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@ import * as dotenv from 'dotenv';

async function bootstrap() {
dotenv.config();
const port = process.env.SERVER_CONSUMER_PORT || 4001;

const rabbitMq = await NestFactory.createMicroservice<MicroserviceOptions>(AppModule, {
const app = await NestFactory.create(AppModule);

app.connectMicroservice<MicroserviceOptions>({
transport: Transport.TCP,
});

app.connectMicroservice<MicroserviceOptions>({
transport: Transport.RMQ,
options: rabbitMqConfig,
});

await rabbitMq.listen();
await app.startAllMicroservices();
await app.listen(port);
}

void bootstrap();

0 comments on commit 4a46745

Please sign in to comment.