NestJS Monorepo Microservices Deployment to Heroku with Shared Files

Viewed 213

Currently, I am building a monorepo microservices with an apigateway using Redis to communicate. I am planning to deploy each services into different dynos in Heroku. Currently, it's pretty straightforward since every service has its own package.json, tsconfig.json, and Procfile. I could deploy them using git subtree The problem occurs when I want to have a shared files. For example I want to share the same DTOs across microservices to minimize bug and error. Does anyone have any idea on how to approach this? Current File Structure:

Project
|    .git
|
|____Apigateway
|    |  Procfile
|    |  package.json
|
|____Microservice 1
|    |  Procfile
|    |  package.json
|
|____Microservice 2
|    |  Profile
|    |  package.json

Desired File Structure:

Project
|    .git
|    create.dto.ts
|    delete.dto.ts
|
|____Apigateway
|    |  Procfile
|    |  package.json
|
|____Microservice 1
|    |  Procfile
|    |  package.json
|
|____Microservice 2
|    |  Profile
|    |  package.json
1 Answers

A possible way to do this is to create a Nest.js library and then add the library as a dependency to the individual services in their respective package.json files using a local path.

Related