{"id":17103364,"url":"https://github.com/farwayer/ws-rpc","last_synced_at":"2026-02-12T09:02:13.166Z","repository":{"id":224863237,"uuid":"187910939","full_name":"farwayer/ws-rpc","owner":"farwayer","description":"Simple, small rfc-correct JSON-RPC 2.0 implementation via websockets","archived":false,"fork":false,"pushed_at":"2025-03-03T21:06:06.000Z","size":7744,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-31T02:26:59.018Z","etag":null,"topics":["api","jsonrpc","msgpack","rpc","websocket"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/farwayer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2019-05-21T20:44:37.000Z","updated_at":"2025-03-03T21:06:10.000Z","dependencies_parsed_at":"2024-02-28T05:28:41.608Z","dependency_job_id":"5478d9dd-0761-4d90-9cf2-f9edf1b5505e","html_url":"https://github.com/farwayer/ws-rpc","commit_stats":null,"previous_names":["farwayer/ws-rpc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/farwayer/ws-rpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farwayer%2Fws-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farwayer%2Fws-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farwayer%2Fws-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farwayer%2Fws-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/farwayer","download_url":"https://codeload.github.com/farwayer/ws-rpc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farwayer%2Fws-rpc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29362201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T08:51:36.827Z","status":"ssl_error","status_checked_at":"2026-02-12T08:51:26.849Z","response_time":55,"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":["api","jsonrpc","msgpack","rpc","websocket"],"created_at":"2024-10-14T15:33:10.338Z","updated_at":"2026-02-12T09:02:13.123Z","avatar_url":"https://github.com/farwayer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ws-rpc\n\n*Simple, small rfc-correct JSON-RPC 2.0 implementation with encoders support*\n\nSupports binary data in requests with `MsgpackEncoder`\n\n## Usage\n\n### Server\n\n```js\nimport {Server} from '@ws-rpc/server'\nimport {MsgpackEncoder} from '@ws-rpc/encoder-msgpack'\n\n// see ws lib options\nlet wss = new Server({\n  port: 8081,\n  encoders: [MsgpackEncoder], // json by default\n  ctx: {db},\n})\n\nlet bookUpsert = async (ctx, data) =\u003e {\n  let {book, created} = await ctx.db.bookUpsert(data)\n  \n  if (created) {\n    ctx.emit('book.created', book) // emit event to current client\n    // ctx.emitAll('book.created', book) // or to all clients\n  }\n  \n  return book\n}\n\nwss.onrpc = async (ctx, method, ...args) =\u003e {\n  switch (method) {\n    case 'book.upsert':\n      return bookUpsert(ctx, ...args)\n    default:\n      ctx.throwMethodNotFound()\n  }\n}\n\nwss.onevent = (name, ...args) =\u003e {\n  // process event from client\n}\n```\n\n### Client\n\n```js\nimport {Client} from '@ws-rpc/client'\nimport {MsgpackEncoder} from '@ws-rpc/encoder-msgpack'\n\nlet wsc = await new Client({\n  url: 'ws://localhost:8080',\n  encoders: [MsgpackEncoder], // json by default\n}).connect()\n\nwsc.onevent = (event, ...args) =\u003e {\n  // process event from server\n}\n\nlet book = await wsc.rpc('book.upsert', {\n  name: 'Dune',\n  author: 'Franklin Patrick Herbert',\n  cover: new Uint8Array(),\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarwayer%2Fws-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffarwayer%2Fws-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarwayer%2Fws-rpc/lists"}