nest
nest copied to clipboard
feat(microservice): add TLS over TCP support
PR Checklist
Please check if your PR fulfills the following requirements:
- [x] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
- [x] Tests for the changes have been added (for bug fixes / features)
- [x] Docs have been added / updated (for bug fixes / features)
PR Type
What kind of change does this PR introduce?
Adds an additional property useTls?: boolean
to the options for client and server. If useTls is set, it intersects the Nodes tls server / client options with the nest server/client options.
If useTls is set to true, it uses node's tls
module instead of net
to allow TCP over TLS support
[ ] Bugfix
[ X ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:
What is the current behavior?
Issue Number: #6745
What is the new behavior?
If useTls === true
then it will use tls
instead of net
to create the server / client and intersect the appropriate options with the nest options
Does this PR introduce a breaking change?
[ ] Yes
[ X ] No
Other information
For docs, should I update the docs in nestjs/docs.nestjs.com
?
I think we could either add another section in: https://docs.nestjs.com/microservices/basics#client
Or make an own page for TCP Client
or TCP TLS Client
Pull Request Test Coverage Report for Build a18b5f60-086f-4c47-a111-2d294565e81c
- 25 of 33 (75.76%) changed or added relevant lines in 4 files are covered.
- No unchanged relevant lines lost coverage.
- Overall coverage decreased (-0.03%) to 94.103%
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
---|---|---|---|
packages/microservices/client/client-tcp.ts | 15 | 23 | 65.22% |
<!-- | Total: | 25 | 33 |
Totals | |
---|---|
Change from base Build 38eae0db-18bc-4193-8057-69d114a8416f: | -0.03% |
Covered Lines: | 5713 |
Relevant Lines: | 6071 |
💛 - Coveralls
For docs, should I update the docs in nestjs/docs.nestjs.com?
Correct
I think we could either add another section in:
Let's add a new section in the TCP chapter
Docs have been updated as well, the PR is linked above
I can add a sample later that I used for testing, should I include a self-signed certificate in the sample? I'm waiting for #7486 to merged, since this includes support for multi-application samples.
I left a few comments. Can we also add an integration test?
Hi, ty for the the feedback I'll try work on this this weekend.
Currently I dont have that much time to work on this @AnisJS09 Do you want to continue?
Okay, I managed to get some time to continue working on this. I worked on the review from @kamilmysliwiec and think I got it sorted.
Looking into integration testing right now. It seems like there are no e2e tests for TCP implemented atm. So what do you want to be covered for TCP clients? Just a simple addition using sync / async / rxjs of and rxjs from + exception and pub / sub. Similar to how its done in the nats example?
TCP tests https://github.com/nestjs/nest/blob/master/integration/microservices/e2e/sum-rpc.spec.ts
Ahh alright. I completely missed that. Will work on this later then and finish this feature request.
Okay, I added the e2e tests. I included a self signed certificate.
@Flusinerd @kamilmysliwiec is this actively being worked on? I would be happy to pick it up
Hi. I don't think so. Feel free to continue
Moving onto this PR https://github.com/nestjs/nest/pull/10628