{"id":18593508,"url":"https://github.com/syed007hassan/grpc-node-ts-example","last_synced_at":"2026-05-06T13:34:12.863Z","repository":{"id":240328882,"uuid":"718148777","full_name":"Syed007Hassan/GRPC-NODE-TS-EXAMPLE","owner":"Syed007Hassan","description":"Learn about gRPC and create a strongly typed application with gRPC communication using Node and Typescript - https://betterprogramming.pub/how-to-use-grpc-with-node-14e073aa1c84","archived":false,"fork":false,"pushed_at":"2023-11-13T14:53:25.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-17T21:46:33.323Z","etag":null,"topics":["auth","grpc","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://aws.amazon.com/compare/the-difference-between-rpc-and-rest/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Syed007Hassan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-13T13:39:40.000Z","updated_at":"2025-02-16T19:43:01.000Z","dependencies_parsed_at":"2024-05-18T03:58:11.536Z","dependency_job_id":null,"html_url":"https://github.com/Syed007Hassan/GRPC-NODE-TS-EXAMPLE","commit_stats":null,"previous_names":["syed007hassan/grpc-node-ts-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Syed007Hassan%2FGRPC-NODE-TS-EXAMPLE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Syed007Hassan%2FGRPC-NODE-TS-EXAMPLE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Syed007Hassan%2FGRPC-NODE-TS-EXAMPLE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Syed007Hassan%2FGRPC-NODE-TS-EXAMPLE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Syed007Hassan","download_url":"https://codeload.github.com/Syed007Hassan/GRPC-NODE-TS-EXAMPLE/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254513225,"owners_count":22083532,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auth","grpc","nodejs","typescript"],"created_at":"2024-11-07T01:12:45.613Z","updated_at":"2026-05-06T13:34:12.809Z","avatar_url":"https://github.com/Syed007Hassan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grpc-node-typescript-example\nA simple Node application with gRPC communication. Written with Typescript to ensure correct typing in client and server. For simplicity purpose there is only one function `login` shared between client and server.\nThe gRPC client and server communicate over a network using the gRPC protocol, which is built on top of HTTP/2. The client makes a remote procedure call (RPC) to the server by calling a method on a client-side stub. This method corresponds to a method defined in the server's service definition (the `auth.proto` file). The client and server use Protocol Buffers (protobuf) to serialize and deserialize the method's input and output data.\n\nHere's a step-by-step breakdown:\n\n1. The client creates a `LoginRequest` object and calls the `login` method on the `AuthServiceClient` stub, passing in the `LoginRequest` and a callback function.\n\n2. The `AuthServiceClient` serializes the `LoginRequest` to a protobuf message and sends it to the server over a HTTP/2 connection.\n\n3. The server receives the protobuf message, deserializes it back into a `LoginRequest` object, and calls the `login` function with this object.\n\n4. The `login` function checks the `LoginRequest` against its list of users, creates a `LoginResult`, and calls the callback function with this result.\n\n5. The server serializes the `LoginResult` to a protobuf message and sends it back to the client over the HTTP/2 connection.\n\n6. The client receives the protobuf message, deserializes it back into a `LoginResult` object, and calls the callback function with this object.\n\ngRPC has several advantages over traditional RESTful APIs:\n\n- **Performance**: gRPC uses HTTP/2, which is faster and more efficient than HTTP/1.1 used by most RESTful APIs. HTTP/2 supports multiplexing, bidirectional streaming, and flow control.\n\n- **Strongly-typed interfaces**: gRPC uses protobuf, which enforces a strong typing system. This can help catch bugs at compile time that would only be caught at runtime with a RESTful API.\n\n- **Bi-directional streaming**: gRPC supports streaming requests and responses, while REST is typically request/response.\n\n- **Language agnostic**: gRPC supports many different languages, making it easy to create microservices in any language that can interoperate with each other.\n\n- **Tooling**: gRPC provides tools like `protoc` to automatically generate client and server code from service definitions, reducing the amount of boilerplate code you have to write.\n\n## Running server\n```\nnpm run server\n```\n\n## Running client\n```\nnpm run client\n```\n\n## Compiling proto file\nAfter any change in `auth.proto` file it needs to be recompiled by running the following command:\n```\nprotoc --plugin=protoc-gen-ts_proto=.\\node_modules\\.bin\\protoc-gen-ts_proto.cmd --ts_proto_out=. ./protos/auth.proto --ts_proto_opt=outputServices=grpc-js,env=node,esModuleInterop=true\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyed007hassan%2Fgrpc-node-ts-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyed007hassan%2Fgrpc-node-ts-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyed007hassan%2Fgrpc-node-ts-example/lists"}