-
-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Split up health indicators into multiple packages #1882
Comments
@Tony133 @kamilmysliwiec @micalevisk Would love your input on this one. |
👍 migrating the codebase would hurt a bit but I believe have dedicated packages will help on maintaining and improving |
Hi @BrunnerLivio, i think it's an interesting idea to separate the health indicators into separate packages, it would make the For example, thanks the on dynamic module guides and examples I found, I made 4 packages / modules for NestJS (knexjs, mongodbdriver, postgresql, mysql) , surely the developer must also be willing to develop and not having everything ready to use, I think this is the real challenge 😁 I hope I have given you some ideas and thanks for asking me for an opinion even if I am not part of the Core Team 😉👍 |
@Tony133 Thanks for your input! I saw that feature before but just glossed over it :)
Maybe I missed something :) |
Hi @BrunnerLivio, for these two points, I'll answer you here below:
This point seems to me the very most complex, at the moment I have never done tests with terminus with webpack to study the behaviors and how to solve the problem. You have done some tests about it ?
For ESM support I think you need to evaluate if all official NestJS modules will support it then yes, otherwise it's better not to think about it right away. |
The problem most certainly lies in the code below. Essentially webpack can't predict whether Terminus is loading a package or not. Splitting the HealthIndicators into a package each would solve this issue because Terminus wouldn't need to load packages, the user would. terminus/lib/utils/checkPackage.util.ts Lines 32 to 40 in 0dfc725
I am aware the ESM is not supported yet. I don't think I could support ESM even if I wanted to at the moment due to third party packages. Nonetheless, it seems like ESM is coming no matter what. With this RFC I could support it when the time comes. If there are other approaches to solve both of these issues I am very open for these suggestions. This RFC is just an idea to address these problems, though if I can avoid this additional complexity then I'd love to go with an alternative :) |
The goal of this RFC is to validate the design with the community, solicit feedback on open questions, and enable experimentation via a non-production-ready prototype included in this proposal.
✏️ Motivation
@nestjs/terminus
currently loads third party packages lazily. For instance, in order to use theTypeOrmHealthIndicator
one must install@nestjs/typeorm
andtypeorm
package.Here is an example of the
TypeOrmHealthIndicator
implementing the package check:terminus/lib/health-indicator/database/typeorm.health.ts
Lines 54 to 56 in 0dfc725
In order to do this,
@nestjs/terminus
check whether these packages can be loaded with the CommonJSrequire
functionterminus/lib/utils/checkPackage.util.ts
Lines 32 to 40 in 0dfc725
This results in multiple pitfalls:
@nestjs/terminus
@nestjs/typeorm
is never referenced in the*.d.ts
files. Since not everyone uses theTypeOrmHealthIndicator
we always have to assume that this package does not exist. Because of this, third party types can also not be exported.terminus/lib/health-indicator/database/typeorm.health.ts
Line 6 in 0dfc725
terminus/lib/health-indicator/database/typeorm.health.ts
Lines 62 to 64 in 0dfc725
🔎 Implementation details
This RFC would try to minimally change implementations of the Health Indicators. The biggest change would be refactoring the different Health Indicators which require third-party dependencies.
The following Health Indicators would need to be extracted to its own package:
TypeOrmHealthIndicator
->@nestjs/terminus-typeorm
SequelizeHealthIndicator
->@nestjs/terminus-sequelize
MongooseHealthIndicator
->@nestjs/terminus-mongoose
MikroOrmHealthIndicator
->@nestjs/terminus-mikroorm
HttpHealthIndicator
->@nestjs/terminus-http
MicroserviceHealthIndicator
->@nestjs/terminus-microservices
GRPCHealthIndicator
->@nestjs/terminus-grpc
The other Indicators could remain in the
@nestjs/terminus
package.@nestjs/terminus
would still hold the logic to execute Health Indicators as well as providing common functionality to write Health Indicators.⬆️ Main benefits of this proposal
@nestjs/terminus
⬇️ Main downsides of this proposal
typeorm @nestjs/typeorm @nestjs/terminus @nestjs/terminus-typeorm
.The text was updated successfully, but these errors were encountered: