{"id":19165732,"url":"https://github.com/loopbackio/loopback4-extension-grpc","last_synced_at":"2025-05-07T12:24:20.328Z","repository":{"id":42658283,"uuid":"108303390","full_name":"loopbackio/loopback4-extension-grpc","owner":"loopbackio","description":"gRPC Extension for LoopBack 4","archived":false,"fork":false,"pushed_at":"2023-12-15T02:26:18.000Z","size":10136,"stargazers_count":18,"open_issues_count":12,"forks_count":8,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-04-27T19:47:36.735Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loopbackio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-25T17:35:46.000Z","updated_at":"2024-05-03T14:51:18.000Z","dependencies_parsed_at":"2024-06-21T14:28:12.382Z","dependency_job_id":"bc1af1d8-458a-404f-8432-c2454e7e2319","html_url":"https://github.com/loopbackio/loopback4-extension-grpc","commit_stats":null,"previous_names":["strongloop/loopback4-extension-grpc"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopbackio%2Floopback4-extension-grpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopbackio%2Floopback4-extension-grpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopbackio%2Floopback4-extension-grpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopbackio%2Floopback4-extension-grpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loopbackio","download_url":"https://codeload.github.com/loopbackio/loopback4-extension-grpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252874881,"owners_count":21817923,"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":[],"created_at":"2024-11-09T09:29:09.080Z","updated_at":"2025-05-07T12:24:20.303Z","avatar_url":"https://github.com/loopbackio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gRPC Extension for LoopBack 4\n\n[![Join the chat at https://gitter.im/strongloop/loopback4-extension-grpc](https://badges.gitter.im/strongloop/loopback4-extension-grpc.svg)](https://gitter.im/strongloop/loopback4-extension-grpc?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n## Overview\n\nThe `@loopback/grpc` component enables LoopBack 4 as a [gRPC](https://grpc.io/) Server. Also it provides with a gRPC decorator to define your RPC Method implementations from your Application Controllers.\n\n## Installation\n\nInstall the `@loopback/grpc` component in your LoopBack 4 Application.\n\n```sh\n$ npm install --save @loopback/grpc\n```\n\n## Component Configuration\n\n```js\nimport {Application} from '@loopback/core';\nimport {GrpcComponent, Config} from '@loopback/grpc';\nimport {GreeterCtrl} from './controllers/greeter/greeter.ctrl';\n// Grpc Configurations are optional.\nconst config: Config.Component = {\n  /* Optional Configs */\n};\n// Pass the optional configurations\nconst app = new Application({\n  grpc: config,\n});\n// Add Grpc as Component\napp.component(GrpcComponent);\n// Bind GreeterCtrl to the LoopBack Application\napp.controller(GreeterCtrl);\n// Start App\napp.start();\n```\n\n## Grpc auto-generated code\n\nThe `@loopback/grpc` extension provides you with auto-generated interfaces and configurations for strict development.\n\nThe extension will automatically look for proto files within your project structure, creating the corresponding typescript interfaces.\n\nExample:\n\n```sh\n- app\n| - controllers\n| | - greeter\n| | | - greeter.proto\n| | | - greeter.ctrl.ts\n```\n\nOnce you start your app for first time it will automatically create your typescript interfaces from the `greeter.proto` file.\n\n```sh\n- app\n| - controllers\n| | - greeter\n| | | - greeter.proto\n| | | - greeter.proto.ts \u003c--- Auto-generated\n| | | - greeter.ctrl.ts\n```\n\nOnce your interfaces and configurations are created, you can start building your controller logic.\n\n## Grpc Controller\n\nThe `@loopback/grpc` component provides you with a handy decorator to implement GRPC Methods within your LoopBack controllers.\n\n`app/controllers/greeter/greeter.ctrl.ts`\n\n```js\nimport {grpc} from '@loopback/grpc';\nimport {Greeter, HelloRequest, HelloReply} from '/greeter.proto';\n/**\n * @class GreeterCtrl\n * @description Implements grpc proto service\n **/\nexport class GreeterCtrl implements Greeter.Service {\n    // Tell LoopBack that this is a Service RPC implementation\n    @grpc(Greeter.SayHello)\n    sayHello(request: HelloRequest): HelloReply {\n        return {message: 'Hello ' + request.name};\n    }\n}\n```\n\n## Proto Example\n\n`app/controllers/greeter/greeter.proto`\n\n```txt\nsyntax = \"proto3\";\npackage greeterpackage;\n\nservice Greeter {\n  // Sends a greeting\n  rpc SayHello (HelloRequest) returns (HelloReply) {}\n}\n\n// The request message containing the user's name.\nmessage HelloRequest {\n  string name = 1;\n}\n\n// The response message containing the greetings\nmessage HelloReply {\n  string message = 1;\n}\n```\n\n## Contribute\n\nGet started by either downloading this project or cloning it as follows:\n\n```sh\n$ git clone https://github.com/strongloop/loopback4-extension-grpc.git\n$ cd loopback4-extension-grpc \u0026\u0026 npm install\n```\n\n## Contributions\n\n* [Guidelines](https://github.com/strongloop/loopback-next/wiki/Contributing#guidelines)\n* [Join the team](https://github.com/strongloop/loopback-next/issues/110)\n\n## Tests\n\nrun `npm test` from the root folder.\n\n## Todo\n\n* Watch for proto changes.\n* Server/Client Streams\n\n## Contributors\n\nSee [all contributors](https://github.com/strongloop/loopback4-extension-grpc/graphs/contributors).\n\n## License\n\nMIT\n\n[grpc]: (https://grpc.io)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floopbackio%2Floopback4-extension-grpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floopbackio%2Floopback4-extension-grpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floopbackio%2Floopback4-extension-grpc/lists"}