DEV Community

Discussion on: Build an API Gateway with NestJs in 10 minutes

Collapse
 
danmt profile image
Daniel Marin

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?