{"id":19642671,"url":"https://github.com/k8w/tsrpc-browser","last_synced_at":"2025-04-28T12:32:53.601Z","repository":{"id":57381821,"uuid":"105236696","full_name":"k8w/tsrpc-browser","owner":"k8w","description":"TSRPC Client for browser","archived":false,"fork":false,"pushed_at":"2024-11-07T12:38:02.000Z","size":406,"stargazers_count":9,"open_issues_count":2,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-07T13:41:26.852Z","etag":null,"topics":["framework","fullstack","k8w","rpc","tsrpc","typescript"],"latest_commit_sha":null,"homepage":null,"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/k8w.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-29T06:14:02.000Z","updated_at":"2024-11-07T12:38:06.000Z","dependencies_parsed_at":"2024-06-18T21:12:55.474Z","dependency_job_id":"9f71127b-1cc2-4053-b879-fb7fb5c7c701","html_url":"https://github.com/k8w/tsrpc-browser","commit_stats":{"total_commits":164,"total_committers":3,"mean_commits":"54.666666666666664","dds":"0.28658536585365857","last_synced_commit":"0ef0ffb3224c7e337a75c60c3affd384b9511108"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k8w%2Ftsrpc-browser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k8w%2Ftsrpc-browser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k8w%2Ftsrpc-browser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k8w%2Ftsrpc-browser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k8w","download_url":"https://codeload.github.com/k8w/tsrpc-browser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224115686,"owners_count":17258239,"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":["framework","fullstack","k8w","rpc","tsrpc","typescript"],"created_at":"2024-11-11T14:14:20.827Z","updated_at":"2025-04-28T12:32:53.592Z","avatar_url":"https://github.com/k8w.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Browser Client of TSRPC\n\n\u003e TSRPC is a TypeScript RPC framework with runtime type checking and binary serialization.\nSee more detail at [https://github.com/k8w/tsrpc](https://github.com/k8w/tsrpc).\n\nOfficial site: https://tsrpc.cn\n\n## Introduction\n`HttpClient` is using `XMLHttpRequest`, and `WebSocketClient` is using `WebSocket` of browser. \nPlatform adapted to `XMLHttpRequest` and `WebSocket` (like `ReactNative`) can also use this library.\n\n## Usage\n```ts\nimport { HttpClient } from 'tsrpc-browser';\nimport { serviceProto } from './shared/protocols/serviceProto';\n\n// Create the Client\nlet client = new HttpClient(serviceProto, {\n    server: 'http://127.0.0.1:3000',\n    logger: console\n});\n\nasync function yourFunc() {\n    // Call API\n    let ret = await client.callApi('Hello', {\n        name: 'World'\n    });\n\n    // Error: ret.err is TsrpcError\n    if (!ret.isSucc) {\n        alert('Error: ' + ret.err.message);\n        return;\n    }\n\n    // Success: ret.res is ResHello\n    alert('Success: ' + ret.res.reply);\n}\n```\n\n## Browser Support\nThe library is compiled to target `ES2015`, so if you need legacy browser support, you can use Babel to transform the final code to `ES5`. After that it can support all these browser:\n- IE8+\n- Chrome\n- Firefox\n- Safari\n- etc...\n\n**Caution**\n1. To support Internet Explorer, you should import `es6-promise` polyfill by yourself.\n2. WebSocket only support IE10+.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk8w%2Ftsrpc-browser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk8w%2Ftsrpc-browser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk8w%2Ftsrpc-browser/lists"}