{"id":13740959,"url":"https://github.com/konsumer/grpc-dynamic-gateway","last_synced_at":"2025-08-19T21:08:02.831Z","repository":{"id":54533290,"uuid":"79599928","full_name":"konsumer/grpc-dynamic-gateway","owner":"konsumer","description":"Like grpc-gateway, but written in node and dynamic.","archived":false,"fork":false,"pushed_at":"2021-02-12T13:27:49.000Z","size":3983,"stargazers_count":111,"open_issues_count":11,"forks_count":27,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-08T21:18:59.248Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/konsumer.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":"2017-01-20T21:25:17.000Z","updated_at":"2025-05-08T08:48:48.000Z","dependencies_parsed_at":"2022-08-13T19:00:20.963Z","dependency_job_id":null,"html_url":"https://github.com/konsumer/grpc-dynamic-gateway","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/konsumer/grpc-dynamic-gateway","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fgrpc-dynamic-gateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fgrpc-dynamic-gateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fgrpc-dynamic-gateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fgrpc-dynamic-gateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/konsumer","download_url":"https://codeload.github.com/konsumer/grpc-dynamic-gateway/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fgrpc-dynamic-gateway/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271222830,"owners_count":24721542,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-08-03T04:00:53.973Z","updated_at":"2025-08-19T21:08:02.804Z","avatar_url":"https://github.com/konsumer.png","language":"JavaScript","funding_links":[],"categories":["Language-Specific","JavaScript"],"sub_categories":["Node.js"],"readme":"# grpc-dynamic-gateway\n\n[![NPM](https://nodei.co/npm/grpc-dynamic-gateway.png?compact=true)](https://nodei.co/npm/grpc-dynamic-gateway/)\n\nThis will allow you to provide a REST-like JSON interface for your gRPC protobuf interface. [grpc-gateway](https://github.com/grpc-ecosystem/grpc-gateway) requires you to genrate a static version of your interface in go, then compile it. This will allow you to run a JSON proxy for your grpc server without generating/compiling.\n\n* Install with `npm i -g grpc-dynamic-gateway`\n* Start with `grpc-dynamic-gateway DEFINITION.proto`\n\nYou can see an example project [here](https://github.com/konsumer/grpcnode/tree/master/example) that shows how to use all the CLI tools, with no code other than your endpoint implementation.\n\n\n# cli\n\n```\nUsage: grpc-dynamic-gateway [options] DEFINITION.proto [DEFINITION2.proto...]\n\nOptions:\n  -?, --help, -h    Show help                                          [boolean]\n  --port, -p        The port to serve your JSON proxy on         [default: 8080]\n  --grpc, -g        The host \u0026 port to connect to, where your gprc-server is\n                    running                         [default: \"localhost:50051\"]\n  -I, --include     Path to resolve imports from.\n                    Support multi include path, but you have to put the proto files\n                    root in first include.\n  --ca              SSL CA cert for gRPC\n  --key             SSL client key for gRPC\n  --cert            SSL client certificate for gRPC\n  --mountpoint, -m  URL to mount server on                        [default: \"/\"]\n  --quiet, -q       Suppress logs                                      [boolean]\n```\n\n# in code\n\nYou can use it in your code, too, as express/connect/etc middleware.\n\n`npm i -S grpc-dynamic-gateway`\n\n```js\nconst grpcGateway = require('grpc-dynamic-gateway')\nconst express = require('express')\nconst bodyParser = require('body-parser')\n\nconst app = express()\napp.use(bodyParser.json())\napp.use(bodyParser.urlencoded({ extended: false }))\n\n// load the proxy on / URL\napp.use('/', grpcGateway(['api.proto'], '0.0.0.0:5051'))\n\nconst port = process.env.PORT || 8080\napp.listen(port, () =\u003e {\n  console.log(`Listening on http://0.0.0.0:${port}`)\n})\n```\n\n# ssl\n\nWith SSL, you will need the Cert Authority certificate, client \u0026 server signed certificate and keys.\n\n\nI generated/signed my demo keys like this:\n\n```\nopenssl genrsa -passout pass:1111 -des3 -out ca.key 4096\nopenssl req -passin pass:1111 -new -x509 -days 365 -key ca.key -out ca.crt -subj  \"/C=US/ST=Oregon/L=Portland/O=Test/OU=CertAuthority/CN=localhost\"\nopenssl genrsa -passout pass:1111 -des3 -out server.key 4096\nopenssl req -passin pass:1111 -new -key server.key -out server.csr -subj  \"/C=US/ST=Oregon/L=Portland/O=Test/OU=Server/CN=localhost\"\nopenssl x509 -req -passin pass:1111 -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt\nopenssl rsa -passin pass:1111 -in server.key -out server.key\nopenssl genrsa -passout pass:1111 -des3 -out client.key 4096\nopenssl req -passin pass:1111 -new -key client.key -out client.csr -subj \"/C=US/ST=Oregon/L=Portland/O=Test/OU=Client/CN=localhost\"\nopenssl x509 -passin pass:1111 -req -days 365 -in client.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out client.crt\nopenssl rsa -passin pass:1111 -in client.key -out client.key\n```\n\nThen use it like this:\n\n```\ngrpc-dynamic-gateway --ca=ca.crt --key=client.key --cert=client.crt api.proto\n```\n\nYou can use SSL in code, like this:\n\n```js\nconst grpc = require('grpc')\nconst credentials = grpc.credentials.createSsl(\n  fs.readFileSync(yourca),\n  fs.readFileSync(yourkey),\n  fs.readFileSync(yourcert)\n)\napp.use('/', grpcGateway(['api.proto'], '0.0.0.0:5051', credentials))\n```\n\n# OpenAPI (a.k.a Swagger)\n\n[Protoc](https://github.com/google/protobuf) can generate a OpenAPI description of your RPC endpoints, if you have [protoc-gen-openapiv2](https://github.com/grpc-ecosystem/grpc-gateway/tree/master/protoc-gen-openapiv2) installed:\n\n```\nprotoc DEFINITION.proto --openapiv2_out=logtostderr=true:.\n```\n\n# docker\n\nThere is one required port, and a volume that will make it easier:\n\n- `/api.proto` - your proto file\n- `8080` - the exposed port\n\nThere is also an optional environment variable: `GRPC_HOST` which should resolve to your grpc server (default `0.0.0.0:5051`)\n\nSo to run it, try this:\n\n```\ndocker run -v $(pwd)/your.proto:/api.proto -p 8080:8080 -e \"GRPC_HOST=0.0.0.0:5051\" -rm -it konsumer/grpc-dynamic-gateway\n```\n\nIf you want to do something different, the exposed `CMD` is the same as `grpc-dynamic-gateway` CLI, above.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonsumer%2Fgrpc-dynamic-gateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkonsumer%2Fgrpc-dynamic-gateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonsumer%2Fgrpc-dynamic-gateway/lists"}