Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mabuonomo/example-nestjs-microservices-grpc
NestJS + gRPC: a multi microservices example
https://github.com/mabuonomo/example-nestjs-microservices-grpc
docker grpc microservices nestjs nestjs-grpc prisma proto protobuf
Last synced: 2 days ago
JSON representation
NestJS + gRPC: a multi microservices example
- Host: GitHub
- URL: https://github.com/mabuonomo/example-nestjs-microservices-grpc
- Owner: mabuonomo
- License: apache-2.0
- Created: 2019-12-23T21:33:34.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-24T05:22:02.000Z (almost 2 years ago)
- Last Synced: 2023-11-07T19:48:48.281Z (about 1 year ago)
- Topics: docker, grpc, microservices, nestjs, nestjs-grpc, prisma, proto, protobuf
- Language: TypeScript
- Homepage:
- Size: 3.48 MB
- Stars: 143
- Watchers: 2
- Forks: 19
- Open Issues: 64
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NestJS + gRPC: a multi microservices example
This repo show as to configure a multi microservices stack in NestJS using gRPC in docker environment.
## Docker Stack
- 3 NestJS microservices
- 1 NestJS client
- 1 Prisma server
- 1 DB MySQL## Run it!
```bash
make init
docker-compose up
```Navigate to
```
http://localhost:3000/test/client1
http://localhost:3000/test/client2http://localhost:3000/test/client_prisma_add
http://localhost:3000/test/client_prisma_get
```## Protobuf (*.proto) builder
This project use ts-proto library to generate interfaces from *.proto files.Just add/edit some proto file into proto folder, then run:
```sh
make proto_build
```For example, this proto file:
```protobuf
syntax = "proto3";
import "google/protobuf/empty.proto";package micr_prisma;
service MicrService {
rpc FindOne (google.protobuf.Empty) returns (UserList) {}
rpc Save (google.protobuf.Empty) returns (User) {}
}message User {
string id = 1;
string name = 2;
string surname = 3;
}message UserList {
repeated User users = 1;
}
```generate the following typescript code:
```ts
/* eslint-disable */
import { Empty } from './google/protobuf/empty';export interface User {
id: string;
name: string;
surname: string;
}export interface UserList {
users: User[];
}export interface MicrService {
FindOne(request: Empty): Promise;
Save(request: Empty): Promise;
}
```
We can use these interfaces in NestJS project easily.## Documentation
- Blog
## Thanks to