A developer installs gRPC dependencies in a NestJS project and creates protocol buffer (.proto) definitions for authentication, payments, and notification microservices. The process includes defining services, messages, and RPC methods to facilitate communication between services while ensuring type safety.
Length 12:30
Captions English (Generated), Spanish (Auto-translated), French (Auto-translated), Korean (Auto-translated), Portuguese (Auto-translated), Vietnamese (Auto-translated) #nestjs #grpc #microservices #typescript #protobuf #programming #coding #backend #development
0:00 All right, so to get started integrating gRPC with 0:03 our 0:04 microservices, we're gonna need to install some 0:06 dependencies 0:08 that NestJS will use underneath the hood to use gRPC. 0:13 Now, as I've done typically, I'm going to keep the completed 0:16 code for this gRPC work in a new branch 0:20 called gRPC. So if you wanna see the 0:24 completed project with gRPC, you can check out this 0:28 branch and follow along there. 0:30 I'm gonna check out the main branch and work off of this on a clean slate. 0:36 So let's go ahead and get started by installing those 0:38 dependencies. 0:39 So I will run pnpm install 0:42 --save 0:44 gr @grp c/grp 0:48 cjs and 0:50 grpc/protoloader. 0:53 We're also gonna install ts proto, 0:56 ts-proto, which is gonna allow us to convert our 0:59 protobuf 1:00 definition files, which is the shape of our data and 1:04 services in a language that gRPC understands. 1:07 It's gonna allow us to convert those files into TypeScript code 1:11 so that we don't have to keep duplicating all of that, and it's also gonna allow 1:15 us to integrate this in NestJS very easily. 1:19 So let's go ahead and let these dependencies finish 1:22 installing. 1:24 So now that we have our dependencies installed, let's go back to our project, 1:28 and we're gonna create a new folder at the root of our project called 1:32 Proto. And this is where the definitions, those protobuf definitions 1:36 that I mentioned earlier, this is where we're gonna host all of them, 1:40 and this is going to be the data and 1:44 services that act on those data. It's gonna be a description of that 1:47 in a language that gRPC understands. 1:51 And the big advantage of using these files is that we can use them on any 1:55 client, so whether it's our backend here, a mobile app, a web 1:59 page, any application that wants to use these protos can be
The rest of the transcript is for members.
Sign in