{"id":13740939,"url":"https://github.com/paralin/grpc-bus","last_synced_at":"2025-03-21T18:33:21.683Z","repository":{"id":53829841,"uuid":"71490684","full_name":"paralin/grpc-bus","owner":"paralin","description":"Call GRPC services (even streams!) from the browser over any two-way socket to Node and soon Go.","archived":false,"fork":false,"pushed_at":"2017-08-16T21:52:02.000Z","size":98,"stargazers_count":43,"open_issues_count":9,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-13T15:07:28.784Z","etag":null,"topics":[],"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/paralin.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":"2016-10-20T18:09:26.000Z","updated_at":"2023-08-20T11:25:04.000Z","dependencies_parsed_at":"2022-08-22T08:00:40.025Z","dependency_job_id":null,"html_url":"https://github.com/paralin/grpc-bus","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paralin%2Fgrpc-bus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paralin%2Fgrpc-bus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paralin%2Fgrpc-bus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paralin%2Fgrpc-bus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paralin","download_url":"https://codeload.github.com/paralin/grpc-bus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221817677,"owners_count":16885596,"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-08-03T04:00:53.792Z","updated_at":"2024-10-28T10:37:09.449Z","avatar_url":"https://github.com/paralin.png","language":"TypeScript","funding_links":[],"categories":["Language-Specific"],"sub_categories":["Node.js"],"readme":"GRPC Bus [![codecov](https://codecov.io/gh/paralin/grpc-bus/branch/master/graph/badge.svg)](https://codecov.io/gh/paralin/grpc-bus) [![Build Status](https://travis-ci.org/paralin/grpc-bus.svg?branch=master)](https://travis-ci.org/paralin/grpc-bus) [![npm version](https://badge.fury.io/js/grpc-bus.svg)](https://badge.fury.io/js/grpc-bus) [![dependencies Status](https://david-dm.org/paralin/grpc-bus/status.svg)](https://david-dm.org/paralin/grpc-bus) [![devDependencies Status](https://david-dm.org/paralin/grpc-bus/dev-status.svg)](https://david-dm.org/paralin/grpc-bus?type=dev)\n========\n\n**NOTE:** Development on grpc-bus is currently suspended as I have transitioned to Go from Node in all of my projects. If you want to adopt the project, let me know!\n\nGRPC-bus is a mechanism to call GRPC services from the browser using a Node.JS server as a proxy. The link between the browser and Node.JS is defined by the user, but could be something like a WebSocket.\n\nThe server and client are expected to share the same / similar protobuf tree. For example, the same result should come from the following code on both the client and server:\n\n```js\nbuilder.Build(\"mynamespace.MyType\");\n```\n\nIn this way the client can implement the ProtoBuf.JS RPC interfaces in the browser. Then, the grpc-bus package does the following:\n\n - Keep track of connections to desired remote servers\n - Make service calls on behalf of the client\n - Keep track of streaming calls and pipe these back to the client accordingly.\n\nThus, we can call GRPC servers from the browser via a Node.JS websocket stream.\n\nExample\n=======\n\nA full example can be found in the end-to-end tests under `./src/index.spec.ts`.\n\nFirst, create your client, and give it a way to communicate with the server:\n\n```js\nvar protoTree = ProtobufJS.load('...');\nvar grpcBus = require('grpc-bus');\n// MySendFunction takes a message object.\n// This message should be passed to handleMessage on the server.\nvar client = new grpcBus.Client(protoTree, mySendFunction);\nvar tree = client.buildTree();\ntree.MyService('localhost:3000').then(function(service) {\n  service.MyMethod({hello: 'world'}, function(err, resp) {\n    console.log(resp);\n    service.end();\n  });\n});\n```\n\nYou should always call `service.end()` when you are done with a service handle, so the server knows it's safe to dispose it.\n\nYou'll notice that inside the `then` block the API is exactly the same as the Node GRPC api.\n\nInternals\n=========\n\nA client must first be instantiated. The client object has to be given a function to send a message to the server, and should be called when the server sends a message to it. In this way, the user can implement their own transport, for example, websockets.\n\nNext, the client can instantiate a service object, similar to the GRPC Node API. This returns a promise, resolved with a service handle with stubs for the methods on the service. The server will de-duplicate and re-use multiple service objects internally.\n\nThe client can then make calls against the remote service with the same API as the GRPC Node implementation.\n\nWhen the client is done with a service object, it should dispose it. When all service objects are disposed, the server will disconnect from the service and forget the credentials used.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparalin%2Fgrpc-bus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparalin%2Fgrpc-bus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparalin%2Fgrpc-bus/lists"}