{"id":26616468,"url":"https://github.com/chatmail/yerpc","last_synced_at":"2025-04-10T05:54:05.738Z","repository":{"id":41106228,"uuid":"450045462","full_name":"chatmail/yerpc","owner":"chatmail","description":"An ergonomic JSON-RPC server library in Rust with autocreated TypeScript client and OpenRPC specification","archived":false,"fork":false,"pushed_at":"2025-03-29T19:17:43.000Z","size":242,"stargazers_count":41,"open_issues_count":7,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-10T00:32:30.308Z","etag":null,"topics":["chatmail","json","json-rpc","jsonrpc","openrpc","rpc","rpc-framework","rust","typescript"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chatmail.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","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":{"custom":["https://delta.chat/en/contribute#donate-money"],"liberapay":"delta.chat","open_collective":"delta-chat"}},"created_at":"2022-01-20T10:10:33.000Z","updated_at":"2025-04-03T05:48:36.000Z","dependencies_parsed_at":"2023-02-13T04:16:00.588Z","dependency_job_id":"32002b54-541e-4d4f-a79f-6cd68c3518ad","html_url":"https://github.com/chatmail/yerpc","commit_stats":{"total_commits":104,"total_committers":6,"mean_commits":"17.333333333333332","dds":"0.40384615384615385","last_synced_commit":"7d3b0173d620dfefa35bfa9e34355ad72b276220"},"previous_names":["frando/yerpc","chatmail/yerpc"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chatmail%2Fyerpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chatmail%2Fyerpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chatmail%2Fyerpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chatmail%2Fyerpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chatmail","download_url":"https://codeload.github.com/chatmail/yerpc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248166927,"owners_count":21058480,"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":["chatmail","json","json-rpc","jsonrpc","openrpc","rpc","rpc-framework","rust","typescript"],"created_at":"2025-03-24T07:08:36.326Z","updated_at":"2025-04-10T05:54:05.716Z","avatar_url":"https://github.com/chatmail.png","language":"Rust","funding_links":["https://delta.chat/en/contribute#donate-money","https://liberapay.com/delta.chat","https://opencollective.com/delta-chat"],"categories":[],"sub_categories":[],"readme":"# yerpc\n\n[![docs.rs](https://img.shields.io/badge/docs.rs-documentation-green.svg)](https://docs.rs/yerpc)\n[![Crates.io](https://img.shields.io/crates/v/typescript-type-def.svg)](https://crates.io/crates/yerpc)\n\nA JSON-RPC 2.0 server handler for Rust, with automatic generation of a TypeScript client.\n\nyerpc includes (optional) integration with `axum` and `tokio-tungstenite` for easy setup and usage. Enable the `support-axum` and `support-tungstenite`  feature flags for these integrations.\n\n## Example\n```rust\nuse axum::{\n    extract::ws::WebSocketUpgrade, http::StatusCode, response::Response, routing::get, Router,\n};\nuse std::net::SocketAddr;\nuse yerpc::{rpc, RpcClient, RpcSession};\nuse yerpc::axum::handle_ws_rpc;\n\nstruct Api;\n\n#[rpc(all_positional, ts_outdir = \"typescript/generated\", openrpc_outdir = \"./\")]\nimpl Api {\n    async fn shout(\u0026self, msg: String) -\u003e String {\n        msg.to_uppercase()\n    }\n    async fn add(\u0026self, a: f32, b: f32) -\u003e f32 {\n        a + b\n    }\n}\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), std::io::Error\u003e {\n    let api = Api {}\n    let app = Router::new()\n        .route(\"/rpc\", get(handler))\n        .layer(Extension(api));\n    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));\n    eprintln!(\"listening on {}\", addr);\n    axum::Server::bind(\u0026addr)\n        .serve(app.into_make_service())\n        .await\n        .unwrap();\n\n    Ok(())\n}\n\nasync fn handler(\n    ws: WebSocketUpgrade,\n    Extension(api): Extension\u003cApi\u003e,\n) -\u003e Response {\n    let (client, out_channel) = RpcClient::new();\n    let session = RpcSession::new(client, api);\n    handle_ws_rpc(ws, out_channel, session).await\n}\n```\n\nNow you can connect any JSON-RPC client to `ws://localhost:3000/rpc` and call the `shout` and `add` methods.\n\nAfter running `cargo test` you will find an autogenerated TypeScript client in the `typescript/generated` folder and an `openrpc.json` file in the root fo your project.\nSee [`examples/axum`](examples/axum) for a full usage example with Rust server and TypeScript client for a chat server.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchatmail%2Fyerpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchatmail%2Fyerpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchatmail%2Fyerpc/lists"}