{"id":41489210,"url":"https://github.com/eggjs/egg-rpc-generator","last_synced_at":"2026-01-23T18:16:19.149Z","repository":{"id":57220717,"uuid":"136558430","full_name":"eggjs/egg-rpc-generator","owner":"eggjs","description":"RPC tools for egg framework","archived":false,"fork":false,"pushed_at":"2023-06-16T13:26:17.000Z","size":87,"stargazers_count":37,"open_issues_count":3,"forks_count":5,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-10-08T00:33:55.597Z","etag":null,"topics":["eggjs","rpc","sofa-rpc"],"latest_commit_sha":null,"homepage":null,"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/eggjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2018-06-08T02:56:27.000Z","updated_at":"2023-06-16T13:25:29.000Z","dependencies_parsed_at":"2022-08-29T04:01:41.628Z","dependency_job_id":"608f5191-e92c-4957-bb60-8d3a5afff475","html_url":"https://github.com/eggjs/egg-rpc-generator","commit_stats":{"total_commits":20,"total_committers":5,"mean_commits":4.0,"dds":"0.19999999999999996","last_synced_commit":"d1d0d93329ce7fe5ab134ddc2ed925997effd2da"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/eggjs/egg-rpc-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fegg-rpc-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fegg-rpc-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fegg-rpc-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fegg-rpc-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eggjs","download_url":"https://codeload.github.com/eggjs/egg-rpc-generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fegg-rpc-generator/sbom","scorecard":{"id":368769,"data":{"date":"2025-08-11","repo":{"name":"github.com/eggjs/egg-rpc-generator","commit":"d1d0d93329ce7fe5ab134ddc2ed925997effd2da"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/18 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/nodejs.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/eggjs/egg-rpc-generator/nodejs.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/eggjs/egg-rpc-generator/release.yml/master?enable=pin","Info:   0 out of   2 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":6,"reason":"binaries present in source code","details":["Warn: binary detected: test/fixtures/apps/jar2proxy/assembly/dubbo-demo-api-1.0-SNAPSHOT-sources.jar:1","Warn: binary detected: test/fixtures/apps/jar2proxy/assembly/dubbo-demo-api-1.0-SNAPSHOT.jar:1","Warn: binary detected: test/fixtures/apps/jar2proxy/assembly/jar2proxy-facade-1.0.0-sources.jar:1","Warn: binary detected: test/fixtures/apps/jar2proxy/assembly/jar2proxy-facade-1.0.0.jar:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 19 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T12:29:44.168Z","repository_id":57220717,"created_at":"2025-08-18T12:29:44.168Z","updated_at":"2025-08-18T12:29:44.168Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28697428,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T17:25:48.045Z","status":"ssl_error","status_checked_at":"2026-01-23T17:25:47.153Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["eggjs","rpc","sofa-rpc"],"created_at":"2026-01-23T18:16:17.920Z","updated_at":"2026-01-23T18:16:19.136Z","avatar_url":"https://github.com/eggjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# egg-rpc-generator\n\n[![NPM version][npm-image]][npm-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/egg-rpc-generator.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/egg-rpc-generator\n[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-rpc-generator.svg?style=flat-square\n[codecov-url]: https://codecov.io/github/eggjs/egg-rpc-generator?branch=master\n[download-image]: https://img.shields.io/npm/dm/egg-rpc-generator.svg?style=flat-square\n[download-url]: https://npmjs.org/package/egg-rpc-generator\n\nRPC tools for egg framework\n\n## Install\n\n```bash\n$ npm i egg-rpc-generator -g\n```\n\n## Usage\n\n### 1. Command-line interface (cli) usage\n\n```bash\n$ egg-rpc-generator -h\n\n  Usage: egg-rpc-generator [options]\n\n  Options:\n\n    -b, --base [base]            the base directory of the project\n    -p, --plugin [plugin]        the plugins used in generation process\n    -f, --framework [framework]  specify framework that can be absolute path or npm package\n    -k, --keep-case              keeps field casing instead of converting to camel case\n    -h, --help                   output usage information\n```\n\n- `-b, --base` the egg project root folder, default is `process.cwd()`\n- `-p, --plugin` the plugins will be used in generation process, by default `protobuf` plugin will be activated\n- `-f, --framework` specify the custom egg framework name or path\n- `-k, --keep-case` keeps field casing instead of converting to camel case\n\n\nrun `egg-rpc-generator` under the egg project root folder\n\n```bash\n$ egg-rpc-generator\n\nCreate /home/admin/project proxy\n[ProtoRPCPlugin] found \"com.rpc.test.ProtoService\" in proto file\n[ProtoRPCPlugin] save all proto info into \"/home/admin/project/run/proto.json\"\n------------------------------------------------\nAll done\n```\n\n### 2. Usage with `package.json` scripts\n\n```js\n{\n  \"scripts\": {\n    \"rpc\": \"egg-rpc-generator\"\n  }\n}\n```\n\nRun arbitrary package scripts\n\n```bash\n$ npm run rpc\n\nCreate /home/admin/project proxy\n[ProtoRPCPlugin] found \"com.rpc.test.ProtoService\" in proto file\n[ProtoRPCPlugin] save all proto info into \"/home/admin/project/run/proto.json\"\n------------------------------------------------\nAll done\n```\n\n## Build-in Plugin\n\n### Protobuf Plugin\nTo generate rpc schema and proxy files from *.proto files\n\n- step 1: put your *.proto files into `$base/proto` folder\n\n```\n.\n├── app\n├── config\n│   ├── config.default.js\n│   └── proxy.js\n├── package.json\n└── proto\n    └── ProtoService.proto\n```\n\n`proto/ProtoService.proto`\n\n```proto\nsyntax = \"proto3\";\n\npackage com.alipay.sofa.rpc.test;\n\n// 可选\noption java_multiple_files = false;\n\nservice ProtoService {\n  rpc echoObj (EchoRequest) returns (EchoResponse) {}\n}\n\nmessage EchoRequest {\n  string name = 1;\n  Group group = 2;\n}\n\nmessage EchoResponse {\n  int32 code = 1;\n  string message = 2;\n}\n\nenum Group {\n  A = 0;\n  B = 1;\n}\n```\n\n- step 2: config the config/proxy.js\n\n```js\nmodule.exports = {\n  group: 'SOFA',\n  errorAsNull: false,\n  services: [{\n    appName: 'pb',\n    responseTimeout: 100,\n    api: {\n      ProtoService: {\n        interfaceName: 'com.alipay.sofa.rpc.test.ProtoService',\n        version: '1.0',\n        method: {\n          echoObj: {\n            responseTimeout: 3000,\n          },\n        },\n      },\n    },\n  }],\n};\n```\n\n- step 3: run `egg-rpc-generator` under the project folder\n\nwill generate `app/proxy/ProtoService.js` and `run/proto.json`\n```bash\n.\n├── app\n│   └── proxy\n│       └── ProtoService.js\n├── config\n│   ├── config.default.js\n│   └── proxy.js\n├── package.json\n├── proto\n│   └── ProtoService.proto\n└── run\n    └── proto.json\n```\n\n`app/proxy/ProtoService.js`\n```js\n// Don't modified this file, it's auto created by egg-rpc-generator\n\n'use strict';\n\nconst path = require('path');\n\n/* eslint-disable */\n/* istanbul ignore next */\nmodule.exports = app =\u003e {\n  const consumer = app.rpcClient.createConsumer({\n    interfaceName: 'com.alipay.sofa.rpc.test.ProtoService',\n    targetAppName: 'pb',\n    version: '1.0',\n    group: 'SOFA',\n    proxyName: 'ProtoService',\n    responseTimeout: 100,\n  });\n\n  if (!consumer) {\n    // `app.config['pb.rpc.service.enable'] = false` will disable this consumer\n    return;\n  }\n\n  app.beforeStart(async() =\u003e {\n    await consumer.ready();\n  });\n\n  class ProtoService extends app.Proxy {\n    constructor(ctx) {\n      super(ctx, consumer);\n    }\n\n    async echoObj(req) {\n      return await consumer.invoke('echoObj', [ req ], {\n        ctx: this.ctx,\n        responseTimeout: 3000,\n      });\n    }\n  }\n\n  return ProtoService;\n};\n/* eslint-enable */\n```\n\n### Jar2Proxy Plugin\n\nTo generate rpc proxy from jar.\n\n- step 1: config `config/proxy.js`\n\nPlease refer to [jar2proxy configuration](https://github.com/eggjs/jar2proxy#config-configproxyjs) for detail.\n\n- step 2: put jar file into `$app_root/assembly` folder\n\n```bash\n.\n├── app\n├── assembly\n│   ├── dubbo-demo-api-1.0-SNAPSHOT-sources.jar\n│   ├── dubbo-demo-api-1.0-SNAPSHOT.jar\n│   ├── jar2proxy-facade-1.0.0-sources.jar\n│   └── jar2proxy-facade-1.0.0.jar\n├── config\n│   └── proxy.js\n└── package.json\n```\n\n- step 3: run `egg-rpc-generator` under the project folder\n\nwill generate following folders:\n\n  - `app/proxy` all proxy files.\n  - `app/proxy_class`  all class definitions\n  - `app/proxy_enums`  all enums definitions\n\n### Jsdoc2Jar\n\nTo generator jave interface definitions(jars) from JavaScript comments.\n\n- step 1: config `config/config.default.js`\n\n```js\nexports.rpc = {\n  server: {\n    namespace: 'com.eggjs.xxx',\n    // group: 'xxx',\n    // version: '1.0.0',\n    // pom: {\n    //   version: '1.0.0',\n    //   groupId: 'com.eggjs.facade',\n    //   artifactId: 'your-artifactId',\n    // },\n  },\n};\n```\n\n- step 2: write rpc service with js comments\n\n```js\n// $app_root/rpc/HelloService.js\n\n/**\n * say hello\n * @param {String} name - user name\n * @return {String} hello words\n * @rpc\n */\nexports.sayHello = async function (name) {\n  return 'hello ' + name;\n};\n```\n\n- step 3: run `egg-rpc-generator` under the project folder\n\nwill generate:\n  - `$app_root/src`: java interface definitions source code\n  - `$app_root/target`: the output of `mvn clean install`\n\n\n## Write Your Plugin\n\nYou can write your own egg-rpc-generator plugin.\n\n- Write a plugin, and publish it to NPM.\n\n```js\nmodule.exports = async (units, { baseDir }) =\u003e {\n  // do something\n};\n```\n\n- Use plugin:\n\ninstall plugin from NPM, then use it with egg-rpc-generator:\n\n```\n$ egg-rpc-generator -p pluginName1,pluginName2,...\n```\n\n## License\n\n[MIT](LICENSE)\n\n\u003c!-- GITCONTRIBUTOR_START --\u003e\n\n## Contributors\n\n|[\u003cimg src=\"https://avatars.githubusercontent.com/u/1207064?v=4\" width=\"100px;\"/\u003e\u003cbr/\u003e\u003csub\u003e\u003cb\u003egxcsoccer\u003c/b\u003e\u003c/sub\u003e](https://github.com/gxcsoccer)\u003cbr/\u003e|[\u003cimg src=\"https://avatars.githubusercontent.com/u/6186521?v=4\" width=\"100px;\"/\u003e\u003cbr/\u003e\u003csub\u003e\u003cb\u003ezhoukk\u003c/b\u003e\u003c/sub\u003e](https://github.com/zhoukk)\u003cbr/\u003e|\n| :---: | :---: |\n\n\nThis project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Fri Jun 16 2023 21:14:08 GMT+0800`.\n\n\u003c!-- GITCONTRIBUTOR_END --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feggjs%2Fegg-rpc-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feggjs%2Fegg-rpc-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feggjs%2Fegg-rpc-generator/lists"}