{"id":14983597,"url":"https://github.com/openidle/grpc-ts-gen","last_synced_at":"2026-01-03T13:06:22.732Z","repository":{"id":64220473,"uuid":"574141056","full_name":"OpenIdle/grpc-ts-gen","owner":"OpenIdle","description":"Generate GRPC server and client for protobuf definition ","archived":false,"fork":false,"pushed_at":"2023-04-22T20:58:53.000Z","size":108,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T07:39:53.971Z","etag":null,"topics":["grpc","protobuf","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenIdle.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-12-04T14:57:10.000Z","updated_at":"2022-12-18T20:10:55.000Z","dependencies_parsed_at":"2024-09-25T00:30:48.081Z","dependency_job_id":null,"html_url":"https://github.com/OpenIdle/grpc-ts-gen","commit_stats":{"total_commits":40,"total_committers":1,"mean_commits":40.0,"dds":0.0,"last_synced_commit":"d57cb862844dab38bb2d031fe2cf91ec2056bd11"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenIdle%2Fgrpc-ts-gen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenIdle%2Fgrpc-ts-gen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenIdle%2Fgrpc-ts-gen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenIdle%2Fgrpc-ts-gen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenIdle","download_url":"https://codeload.github.com/OpenIdle/grpc-ts-gen/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243864822,"owners_count":20360360,"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":["grpc","protobuf","typescript"],"created_at":"2024-09-24T14:07:34.004Z","updated_at":"2026-01-03T13:06:22.649Z","avatar_url":"https://github.com/OpenIdle.png","language":"TypeScript","readme":"# grpc-ts-gen\n[![npm](https://img.shields.io/npm/v/grpc-ts-gen)](https://www.npmjs.com/package/grpc-ts-gen)\n[![npm downloads](https://img.shields.io/npm/dm/grpc-ts-gen)](https://www.npmjs.com/package/grpc-ts-gen)\n[![Coverage Status](https://coveralls.io/repos/github/OpenIdle/grpc-ts-gen/badge.svg?branch=main)](https://coveralls.io/github/OpenIdle/grpc-ts-gen?branch=main)\n\n`grpc-ts-gen` is a tool for generating a typed grpc server and client from protobuf descriptors.\n\nThis means that the only thing needed for implementing a GRPC service is implementing a simple typescript interface.\n\nGiven this protobuf definition\n```proto\nsyntax = \"proto3\";\n\npackage example.HelloService;\n\nmessage HelloRequest {\n\tstring hello = 1;\n}\n\nmessage HelloResponse {\n\tstring world = 1;\n}\n\nservice HelloService {\n\trpc Hello(HelloRequest) returns (HelloResponse);\n}\n```\n\nThis is the only code needed to implement a server\n\n```ts\nimport { ProtoServer } from \"./sample-out/ProtoServer\";\nimport { IHelloService, HelloRequest, HelloResponse } from \"./sample-out/Example/HelloService\"\nimport { GrpcResponseError } from \"grpc-ts-gen\";\nimport * as grpc from \"@grpc/grpc-js\";\n\nlet server = new ProtoServer(new grpc.Server());\n\nclass HelloService implements IHelloService {\n\tasync Hello(request: HelloRequest): Promise\u003cHelloResponse\u003e {\n\t\tif (request.hello != \"hello\") {\n\t\t\tthrow new GrpcResponseError(\"Expected hello\", grpc.status.INVALID_ARGUMENT)\n\t\t}\n\t\treturn {world: \"world\"};\n\t}\n}\n\nserver.AddHelloService(new HelloService());\n\n```\n\n\n# Installation \u0026 Usage\ngrpc-ts-gen is tested for node 18.x.x but will probably work for earlier version. However, for now 18.x.x is the only officially supported version, this will be changed later when all features are implemented.\n\nInstall using:\n```\nnpm install grpc-ts-gen\n```\nThis is not just a dev dependency, since this library also contains a small helper library for the generated code.\n\nGenerate definitions using:\n```\nnpx grpc-ts-gen --proto-base-path \u003croot protobuf path\u003e --out-path \u003coutput folder\u003e\n```\n\n\n## Options\ngrpc-ts-gen has many options to customize the generated code. A table of the options can be seen here\n\n| Name | Description | Required |\n|------|-------------|----------|\n| `proto-base-path` | The base path for protobuf definition files | ✔️ |\n| `out-path` | The base path for the generated files | ✔️ |\n| `server-name` | The name of the file where the generated server is defined | ❌ |\n| `request-body-as-object` | Supply the request object as parameters as a handler instead of an object | ❌ |\n\nThese options can also be defined in a JSON file called `grpc-ts-gen.config.json`, here they are named with camelCase instead of kebab-case.\n```\n// grpc-ts-gen.config.json\n{\n\t\"protoBasePath\": \"../OpenIdle-Connect/protos\",\n\t\"outPath\": \"testout\",\n\t\"serverName\": \"OpenIdle\",\n\t\"requestBodyAsObject\": true\n}\n```\n\nThe option source is prioritized in this way\n\n1. CLI option\n2. Config file option\n3. Default value\n\nThis means that any option supplied by the command line will overwrite the config file option.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenidle%2Fgrpc-ts-gen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenidle%2Fgrpc-ts-gen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenidle%2Fgrpc-ts-gen/lists"}