{"id":15686883,"url":"https://github.com/lambdalisue/deno-messagepack-rpc","last_synced_at":"2025-05-07T18:51:31.896Z","repository":{"id":157475582,"uuid":"633503672","full_name":"lambdalisue/deno-messagepack-rpc","owner":"lambdalisue","description":"🦕 Deno module that allows for the implementation of MessagePack-RPC using MessagePack as the message schema.","archived":false,"fork":false,"pushed_at":"2024-05-13T02:45:03.000Z","size":111,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-22T13:09:45.968Z","etag":null,"topics":["deno","jsr","messagepack","rpc"],"latest_commit_sha":null,"homepage":"https://jsr.io/@lambdalisue/messagepack-rpc","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/lambdalisue.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},"funding":{"github":"lambdalisue"}},"created_at":"2023-04-27T16:34:34.000Z","updated_at":"2024-05-13T02:44:49.000Z","dependencies_parsed_at":"2024-04-06T11:25:59.786Z","dependency_job_id":"a8294748-3afa-464d-88ae-f14d3d95f36b","html_url":"https://github.com/lambdalisue/deno-messagepack-rpc","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdalisue%2Fdeno-messagepack-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdalisue%2Fdeno-messagepack-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdalisue%2Fdeno-messagepack-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdalisue%2Fdeno-messagepack-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lambdalisue","download_url":"https://codeload.github.com/lambdalisue/deno-messagepack-rpc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252939142,"owners_count":21828715,"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":["deno","jsr","messagepack","rpc"],"created_at":"2024-10-03T17:41:43.396Z","updated_at":"2025-05-07T18:51:31.833Z","avatar_url":"https://github.com/lambdalisue.png","language":"TypeScript","funding_links":["https://github.com/sponsors/lambdalisue"],"categories":[],"sub_categories":[],"readme":"# messagepack-rpc\n\n[![JSR](https://jsr.io/badges/@lambdalisue/messagepack-rpc)](https://jsr.io/@lambdalisue/messagepack-rpc)\n[![Test](https://github.com/lambdalisue/deno-messagepack-rpc/workflows/Test/badge.svg)](https://github.com/lambdalisue/deno-messagepack-rpc/actions?query=workflow%3ATest)\n[![codecov](https://codecov.io/github/lambdalisue/deno-messagepack-rpc/branch/main/graph/badge.svg?token=gXooPigw0y)](https://codecov.io/github/lambdalisue/deno-messagepack-rpc)\n\nThis is a TypeScript module that allows for the implementation of\n[MessagePack-RPC] using [MessagePack] as the message schema.\n\n[deno]: https://deno.land/\n[MessagePack]: https://github.com/msgpack/msgpack/blob/master/spec.md\n[MessagePack-RPC]: https://github.com/msgpack-rpc/msgpack-rpc\n\n## Usage\n\n### Server\n\n```typescript\nimport { assert, is } from \"@core/unknownutil\";\nimport { Session } from \"@lambdalisue/messagepack-rpc\";\n\nasync function handleConnection(conn: Deno.Conn): Promise\u003cvoid\u003e {\n  const session = new Session(conn.readable, conn.writable);\n\n  // Define APIs\n  session.dispatcher = {\n    sum(x, y) {\n      assert(x, is.Number);\n      assert(y, is.Number);\n      return x + y;\n    },\n  };\n\n  // Start the session\n  session.start();\n\n  // Do whatever\n\n  // Shutdown the session\n  await session.shutdown();\n}\n\nconst listener = Deno.listen({ hostname: \"localhost\", port: 8080 });\nfor await (const conn of listener) {\n  handleConnection(conn).catch((err) =\u003e console.error(err));\n}\n```\n\n### Client\n\n```typescript\nimport { Client, Session } from \"@lambdalisue/messagepack-rpc\";\n\nconst conn = await Deno.connect({ hostname: \"localhost\", port: 8080 });\nconst session = new Session(conn.readable, conn.writable);\nconst client = new Client(session);\n\n// Start the session\nsession.start();\n\n// Do whatever\nconsole.log(await client.call(\"sum\", 1, 2)); // 3\nconsole.log(await client.call(\"sum\", 2, 3)); // 5\n\n// Shutdown the session\nawait session.shutdown();\n```\n\nAlthough the original MessagePack-RPC specification does not mention\nbidirectional communication, this module supports it. Therefore, APIs defined on\nthe client side can be called from the server side.\n\n## License\n\nThe code is released under the MIT license, which is included in the\n[LICENSE](./LICENSE) file. By contributing to this repository, contributors\nagree to follow the license for any modifications made.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambdalisue%2Fdeno-messagepack-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flambdalisue%2Fdeno-messagepack-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambdalisue%2Fdeno-messagepack-rpc/lists"}