{"id":18975034,"url":"https://github.com/bufferapp/micro-rpc-client","last_synced_at":"2025-04-19T16:44:59.122Z","repository":{"id":19204709,"uuid":"83087436","full_name":"bufferapp/micro-rpc-client","owner":"bufferapp","description":"Universal JS RPC Client https://github.com/bufferapp/micro-rpc/","archived":false,"fork":false,"pushed_at":"2023-01-06T01:37:11.000Z","size":546,"stargazers_count":2,"open_issues_count":11,"forks_count":4,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-14T06:08:53.363Z","etag":null,"topics":[],"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/bufferapp.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}},"created_at":"2017-02-24T22:16:06.000Z","updated_at":"2021-04-29T18:01:05.000Z","dependencies_parsed_at":"2023-01-13T20:13:56.810Z","dependency_job_id":null,"html_url":"https://github.com/bufferapp/micro-rpc-client","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufferapp%2Fmicro-rpc-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufferapp%2Fmicro-rpc-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufferapp%2Fmicro-rpc-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufferapp%2Fmicro-rpc-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bufferapp","download_url":"https://codeload.github.com/bufferapp/micro-rpc-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249223965,"owners_count":21232842,"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-08T15:17:06.628Z","updated_at":"2025-04-16T09:34:26.745Z","avatar_url":"https://github.com/bufferapp.png","language":"JavaScript","readme":"# deprecated\nAs of the 23rd of September 2024, `micro-rpc-client` will be unmaintained and deprecated. \n\n# micro-rpc-client\n\n[![Build Status](https://travis-ci.org/bufferapp/micro-rpc-client.svg?branch=master)](https://travis-ci.org/bufferapp/micro-rpc-client)\n\nUniversal JS RPC Client https://github.com/bufferapp/buffer-rpc/\n\n## Quickstart\n\nCreate an RPC Client and call an add function\n\n```js\nconst RPCClient = require('micro-rpc-client');\n\nconst client = new RPCClient({\n  url: 'https://localhost:3000/rpc',\n});\n\nconst main = async () =\u003e {\n  const result = await client.call('add', [1, 2]);\n  console.log(result); // 3\n};\nmain();\n```\n\n## Usage\n\nA few examples of how to call client methods\n\n```js\nconst RPCClient = require('micro-rpc-client');\n\nconst client = new RPCClient({\n  url: 'https://localhost:3000/rpc',\n  sendCredentials: 'same-origin', // send cookies on same origin requests\n});\n\nconst main = async () =\u003e {\n  const methods = await client.listMethods();\n  console.log(method);\n  /*\n  [\n    {\n      \"docs\": \"add two numbers\"\n      \"name\": \"add\"\n    },\n    {\n      \"docs\": \"list all available methods\",\n      \"name\": \"methods\"\n    }\n  ]\n  */\n  const result = await client.call('add', [1, 2]);\n  console.log(result); // 3\n};\nmain();\n```\n\n## API\n\n### constructor\n\nCreate an instance of RPCClient\n\n```js\nconst client = new RPCClient({\n  url,\n  sendCredentials,\n});\n```\n\n**url** - _string_ - full url to the RPC Endpoint Server  \n**sendCredentials** - _string_ - when to send things like cookies with a request, passes arguments to the credentials init argument in the fetch API https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters\n\nReturns an instance of the RPC client\n\n### listMethods\n\nList all remote methods on a server\n\n```js\nconst methods = await client.listMethods()\n```\n\nReturns a promise that resolves with a list of the remote methods\n\n### call\n\n```js\nconst result = await client.call(name, args)\n```\n\n**name** - _string_ - name of the remote RPC endpoint  \n**args** - _array_ or _object_ - arguments to pass to the remote RPC endpoint\n\nReturns a promise that resolves with the result and rejects with an error.\n\n## Error Handling\n\nWhen calling a remote function with `call` there are different categories of responses:\n\n### Success\n\nThis is the typical success case\n\n```\nstatusCode = 200\nresult = {} // JSON\n```\n\n### Fail (Handled)\n\nAn error triggered from [createError](https://github.com/bufferapp/buffer-rpc/blob/master/README.md#createerror):\n\n```\nstatusCode = 400\nresult = {\n  error: 'string',\n  code: 1000, // or some custom code\n  handled: true,\n}\n```\n\n### Fail (Unhandled)\n\nAn error triggered from [errorMiddleware](https://github.com/bufferapp/buffer-rpc/blob/master/README.md#createerror):\n\n```\nstatusCode = 500\nresult = {\n  error: 'string',\n  code: 1000, // or some custom code\n  handled: true,\n}\n```\n\n### Fail (Unexpected)\n\nIf the [errorMiddleware](https://github.com/bufferapp/buffer-rpc/blob/master/README.md#createerror) is not hooked up, or something unexpected happened the original error will be thrown.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbufferapp%2Fmicro-rpc-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbufferapp%2Fmicro-rpc-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbufferapp%2Fmicro-rpc-client/lists"}