From 19d9b92ea9583ec84cbb9d8c615675c45479b4f3 Mon Sep 17 00:00:00 2001 From: Justin Timmons Date: Thu, 7 Sep 2023 12:59:10 -0400 Subject: [PATCH 1/2] docs(microservices): clarify hybrid application startup added a note to the microservices section and hybrid application for how to deal with an application with multiple microservices but no HTTP server --- content/faq/hybrid-application.md | 4 +++- content/microservices/basics.md | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/content/faq/hybrid-application.md b/content/faq/hybrid-application.md index f91f3dfd3e..ecbd42c0ae 100644 --- a/content/faq/hybrid-application.md +++ b/content/faq/hybrid-application.md @@ -1,6 +1,6 @@ ### Hybrid application -A hybrid application is one that both listens for HTTP requests, as well as makes use of connected microservices. The `INestApplication` instance can be connected with `INestMicroservice` instances through the `connectMicroservice()` method. +A hybrid application is one that listens for requests from two or more different sources. This can combine an HTTP server with a microservice listener or even just multiple different microservice listeners. The default `createMicroservice` method does not allow for multiple servers so in this case each microservice must be created and started manually. In order to do this, the `INestApplication` instance can be connected with `INestMicroservice` instances through the `connectMicroservice()` method. ```typescript const app = await NestFactory.create(AppModule); @@ -12,6 +12,8 @@ await app.startAllMicroservices(); await app.listen(3001); ``` +> info **Hint** the `app.listen(port)` method starts an HTTP server on the specified address. If your application does not handle HTTP requests then you should use the `app.init()` method instead. + To connect multiple microservice instances, issue the call to `connectMicroservice()` for each microservice: ```typescript diff --git a/content/microservices/basics.md b/content/microservices/basics.md index 142f741c13..30b8748fb4 100644 --- a/content/microservices/basics.md +++ b/content/microservices/basics.md @@ -52,6 +52,8 @@ bootstrap(); > info **Hint** Microservices use the **TCP** transport layer by default. +> info **Hint** Multiple microservice listeners can be instantiated within the same NestJS application if needed as well. See the [Hybrid Application](https://docs.nestjs.com/faq/hybrid-application) section for details on how to do so. + The second argument of the `createMicroservice()` method is an `options` object. This object may consist of two members: From d8160f3f8c4caef4ae4e60129aa690d1608df713 Mon Sep 17 00:00:00 2001 From: Kamil Mysliwiec Date: Mon, 11 Sep 2023 09:57:43 +0200 Subject: [PATCH 2/2] Update content/microservices/basics.md --- content/microservices/basics.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/content/microservices/basics.md b/content/microservices/basics.md index 30b8748fb4..142f741c13 100644 --- a/content/microservices/basics.md +++ b/content/microservices/basics.md @@ -52,8 +52,6 @@ bootstrap(); > info **Hint** Microservices use the **TCP** transport layer by default. -> info **Hint** Multiple microservice listeners can be instantiated within the same NestJS application if needed as well. See the [Hybrid Application](https://docs.nestjs.com/faq/hybrid-application) section for details on how to do so. - The second argument of the `createMicroservice()` method is an `options` object. This object may consist of two members: