{"id":20525829,"url":"https://github.com/rodoufu/rest2grpc","last_synced_at":"2025-04-14T03:51:51.789Z","repository":{"id":55865284,"uuid":"317307105","full_name":"rodoufu/rest2grpc","owner":"rodoufu","description":"Convert HTTP REST to gRPC","archived":false,"fork":false,"pushed_at":"2021-01-22T23:03:26.000Z","size":48,"stargazers_count":5,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-27T17:51:47.790Z","etag":null,"topics":["bridge","express-js","gateway","grpc","grpc-gateway","rest","rest-api","restful"],"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/rodoufu.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}},"created_at":"2020-11-30T18:10:16.000Z","updated_at":"2023-10-20T10:11:22.000Z","dependencies_parsed_at":"2022-08-15T08:01:10.608Z","dependency_job_id":null,"html_url":"https://github.com/rodoufu/rest2grpc","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodoufu%2Frest2grpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodoufu%2Frest2grpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodoufu%2Frest2grpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodoufu%2Frest2grpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rodoufu","download_url":"https://codeload.github.com/rodoufu/rest2grpc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248819353,"owners_count":21166474,"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":["bridge","express-js","gateway","grpc","grpc-gateway","rest","rest-api","restful"],"created_at":"2024-11-15T23:09:56.185Z","updated_at":"2025-04-14T03:51:51.770Z","avatar_url":"https://github.com/rodoufu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rest2grpc\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://travis-ci.com/github/rodoufu/rest2grpc\"\u003e\n    \u003cimg src=\"https://api.travis-ci.com/rodoufu/rest2grpc.svg?branch=main\" alt=\"Current TravisCI build status.\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/rodoufu/rest2grpc/releases\"\u003e\n    \u003cimg src=\"https://badge.fury.io/gh/rodoufu%2Frest2grpc.svg\" alt=\"Current version.\"\u003e\n  \u003c/a\u003e\n  \u003c!--\n  \u003ca href='https://coveralls.io/github/rodoufu/rest2grpc'\u003e\n    \u003cimg src='https://coveralls.io/repos/github/rodoufu/rest2grpc/badge.svg' alt='Coverage Status' /\u003e\n  \u003c/a\u003e\n  --\u003e\n  \u003ca href=\"https://github.com/rodoufu/rest2grpc\"\u003e\n      \u003cimg src=\"https://tokei.rs/b1/github/rodoufu/rest2grpc?category=lines\" alt=\"Current total lines.\"\u003e\n    \u003c/a\u003e\n  \u003ca href=\"https://github.com/rodoufu/rest2grpc/blob/main/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg\" alt=\"License.\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nAvailable at https://www.npmjs.com/package/rest2grpc\n\n## Example\n\nLet's say we have a simple gRPC backend service that we want to expose as a REST endpoint,\nsomething like this protos file (`Example.proto`):\n```proto\nsyntax = \"proto3\";\n\npackage example;\n\nservice Example {\n\trpc SayHello (SayHelloRequest) returns (SayHelloResponse) {}\n}\n\nmessage SayHelloRequest {\n\tstring name = 1;\n}\n\nmessage SayHelloResponse {\n\tstring msg = 1;\n}\n```\n\nWe can use the following configuration (`Example.yaml`) to do so:\n```yaml\nhttp:\n  rules:\n    - selector: example.Example.SayHello\n      get: /sayHelloGet\n      post: /sayHelloPost\n```\n\nThat tells rest2grpc to create 2 endpoints:\n- `/sayHelloGet` answering to GET requests.\n- `/sayHelloPost` answering to POST requests.\n\nBoth requests are translated into gRPC and sent to the namespace `example`, service `Example`, \nand call the method `SayHello`.\n\nNow to call everything you only need to:\n```ts\nimport {Rest2gRPCServer} from 'rest2grpc';\n(async () =\u003e {\n\tconst address = 'localhost:50051';\n\n\tlet configFile = `${__dirname}/Example.yaml`;\n\tconst restServer = new Rest2gRPCServer(console);\n\tconst protoPath = [`${__dirname}/protos`];\n\tconst protoFile = \"Example.proto\";\n\tawait restServer.register(configFile, protoPath, protoFile, address);\n\n\trestServer.start(3000);\n})();\n```\n\n## References\n\n- https://github.com/grpc-ecosystem/grpc-gateway\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodoufu%2Frest2grpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodoufu%2Frest2grpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodoufu%2Frest2grpc/lists"}