{"id":18665044,"url":"https://github.com/lindell/remote-function","last_synced_at":"2025-04-11T22:30:46.382Z","repository":{"id":28737829,"uuid":"119203878","full_name":"lindell/remote-function","owner":"lindell","description":"Make function calls to remote hosts seamlessly","archived":false,"fork":false,"pushed_at":"2023-03-04T02:32:58.000Z","size":836,"stargazers_count":100,"open_issues_count":6,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T15:56:38.272Z","etag":null,"topics":["es6-proxies","json-rpc","json-rpc2","rpc"],"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/lindell.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-27T21:26:20.000Z","updated_at":"2025-02-28T03:02:20.000Z","dependencies_parsed_at":"2024-09-18T18:25:32.140Z","dependency_job_id":"97178bfc-5fa2-47c8-aa63-af8e3a94a9e8","html_url":"https://github.com/lindell/remote-function","commit_stats":{"total_commits":55,"total_committers":5,"mean_commits":11.0,"dds":"0.23636363636363633","last_synced_commit":"0aa25cd3c8cc9cfe4768aedeaa763ec785751e79"},"previous_names":["lindell/smooth-rpc"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindell%2Fremote-function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindell%2Fremote-function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindell%2Fremote-function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindell%2Fremote-function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lindell","download_url":"https://codeload.github.com/lindell/remote-function/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248489488,"owners_count":21112584,"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":["es6-proxies","json-rpc","json-rpc2","rpc"],"created_at":"2024-11-07T08:26:02.339Z","updated_at":"2025-04-11T22:30:45.872Z","avatar_url":"https://github.com/lindell.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Remote Function\n[![Build Status](https://travis-ci.org/lindell/remote-function.svg?branch=master)](https://travis-ci.org/lindell/remote-function)\n[![Coverage Status](https://coveralls.io/repos/github/lindell/remote-function/badge.svg?branch=master)](https://coveralls.io/github/lindell/remote-function?branch=master)\n\nRemote Function is a library for making remote procedure calls in an intuitive way. Just declare functions on the server and call them from the client, that's it! If the function errors, the error will seamlessly be transferred to the calling client. This is done via [JSON RPC 2.0](http://www.jsonrpc.org/specification) which makes it possible to use with other clients. It has _no dependencies_ and works by utilizing [Proxies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) that was introduced with ES6.\n\n## Install\n\n```\nnpm install remote-function\n```\n\n## Example\n\n#### Server\n\nInitiate a server, then just define your function on the server object.\n\n```javascript\nconst server = require('remote-function').createServer();\n\nserver.divide = (arg1, arg2) =\u003e {\n    if (arg2 === 0) {\n        throw new Error(\"Can't divide by zero.\");\n    }\n    return arg1 / arg2;\n};\n```\n\n#### Client\n\nDefine where the server is located when creating a client. Then you can just call the function that is defined at the server and you get a promise that returns what the server function will return. If you are on _\u003e=Node 8.0.0_, you can use it with `await` if you are within an `async` function.\n\n```javascript\nconst remote = require('remote-function').createClient({ host: '127.0.0.1' });\n\nconst result = await remote.divide(12, 3);\nconsole.log(result); // 4\n```\n\nIf an error is thrown on the server:\n```javascript\ntry {\n    const result = await remote.divide(12, 0);\n    console.log(result); // Will not be reached\n} catch (error) {\n    // Get the error thrown on the server, including stacktrace\n}\n```\n\n## Options\n\n#### Server\n\n| Option         | Default     | Description                                  |\n| -------------- | ----------- | -------------------------------------------- |\n| `host`         | `\"0.0.0.0\"` | The host that the server listen on           |\n| `port`         | `6356`      | The port that the server listen on           |\n| `includeStack` | `true`      | Should errors include the server stacktrace? |\n\n#### Client\n\n| Option            | Default                     | Description                         |\n| ----------------- | --------------------------- | ----------------------------------- |\n| `host`            | `\"127.0.0.1\"` | The host that the server listens on |\n| `port`            | `6356`        | The port that the server listens on |\n| `headers`         | `{}`          | Additional request headers          |\n| `connectTimeout`  | `0`           | The socket connection timeout       |\n| `responseTimeout` | `0`           | The response wait timeout           |\n\n`createClient` also supports options from [http.request()](https://nodejs.org/api/http.html#http_http_request_options_callback). For example, you can set `headers` to add extra headers to http request, or `auth` if you need Basic Authentication. You cannot change http request _method_.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flindell%2Fremote-function","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flindell%2Fremote-function","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flindell%2Fremote-function/lists"}