nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
66.89k stars 7.56k forks source link

How to create grpc microservice project and separate server side and client side? #747

Closed chj-damon closed 6 years ago

chj-damon commented 6 years ago

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I saw there's an example in nestjs sample folder, but it creates a grpc microservice project but still uses HTTP request to access.

Expected behavior

I want to create two projects: one is grpc microservice project as server side, another project is a normal nestjs project but with grpc client in it and should connect to the server side. In this way I can deploy the server side separately and it won't affect the client side deployment. This is a common way especially I have many microservices as servers and just one client as gateway or BFF(backend for frontend) to connect with them.

I didn't find any document or articles talk about this architecture. So it would be nice if you can share one example or article about this.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: v5.0.0


For Tooling issues:
- Node version: v9.2  
- Platform:  Mac

Others:

chj-damon commented 6 years ago

I've successfully finished this work.

AntoineMaitre commented 6 years ago

Can you provide more details about how you succeeded ?

chj-damon commented 6 years ago

@AntoineMaitre OK, I think I should create a repository for this. I'll let you know after I've done.

chj-damon commented 6 years ago

@AntoineMaitre https://github.com/chj-damon/nestjs-grpc-server https://github.com/chj-damon/nestjs-grpc-client

you can contact me if you have any questions about them.

AntoineMaitre commented 6 years ago

Excellent, thanks for sharing ! ;) I'll let you know if I have any questions 👍

kmturley commented 5 years ago

Looks like the documentation lives under Microservices > gRPC: https://docs.nestjs.com/microservices/grpc

And the working example here: https://github.com/nestjs/nest/tree/master/sample/04-grpc

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.