My question is can we implement both express application and microservice app in the same NEST.JS application? is it possible as I am handling my API Gateway elsewhere using something different! I want my NEST application to listen to outside HTTP requests and also listen to events emitted by other microservices,
Please suggest on it as I want both, I want my microservice to listen to outside HTTP requests also and also able to communicate with other services through ASYNC Communication like REDIS or KAFKA RABBIT MQ??
Hi Ayush, thanks for taking the time to go through it.
In theory, you can have an HTTP service AND a microservice inside the same project, in NestJs there's a main.ts file that works as an entry point, that's where you usually start the app (whether it's an express HTTP server or a microservice), you can modify the main.ts file so it runs both.
Now, my recommendation is to have 2 NestJs applications:
Microservice (Let's call it MS-1)
HTTP server using express that registers MS-1. (Like I did for the API Gateway of the article)
This way you can "send stuff" to your Microservice using an HTTP Service. Is there a practical reason you can't have the two services?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
My question is can we implement both express application and microservice app in the same NEST.JS application? is it possible as I am handling my API Gateway elsewhere using something different! I want my NEST application to listen to outside HTTP requests and also listen to events emitted by other microservices,
Please suggest on it as I want both, I want my microservice to listen to outside HTTP requests also and also able to communicate with other services through ASYNC Communication like REDIS or KAFKA RABBIT MQ??
Hi Ayush, thanks for taking the time to go through it.
In theory, you can have an HTTP service AND a microservice inside the same project, in NestJs there's a
main.ts
file that works as an entry point, that's where you usually start the app (whether it's an express HTTP server or a microservice), you can modify the main.ts file so it runs both.Now, my recommendation is to have 2 NestJs applications:
This way you can "send stuff" to your Microservice using an HTTP Service. Is there a practical reason you can't have the two services?