{"id":25983742,"url":"https://github.com/vasyas/typescript-rest-rpc","last_synced_at":"2025-06-20T19:37:11.552Z","repository":{"id":30446962,"uuid":"123642336","full_name":"vasyas/typescript-rest-rpc","owner":"vasyas","description":"RPC over REST for Typescript clients and servers","archived":false,"fork":false,"pushed_at":"2022-12-07T10:22:58.000Z","size":213,"stargazers_count":5,"open_issues_count":9,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T03:51:05.833Z","etag":null,"topics":["api","javascript","nodejs","rest","restful","rpc","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vasyas.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}},"created_at":"2018-03-02T23:41:02.000Z","updated_at":"2023-09-14T07:41:33.000Z","dependencies_parsed_at":"2023-01-14T16:58:51.940Z","dependency_job_id":null,"html_url":"https://github.com/vasyas/typescript-rest-rpc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vasyas/typescript-rest-rpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasyas%2Ftypescript-rest-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasyas%2Ftypescript-rest-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasyas%2Ftypescript-rest-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasyas%2Ftypescript-rest-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vasyas","download_url":"https://codeload.github.com/vasyas/typescript-rest-rpc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasyas%2Ftypescript-rest-rpc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261005435,"owners_count":23095842,"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":["api","javascript","nodejs","rest","restful","rpc","typescript"],"created_at":"2025-03-05T10:32:23.465Z","updated_at":"2025-06-20T19:37:06.539Z","avatar_url":"https://github.com/vasyas.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"This package is deprecated in favor of https://github.com/vasyas/push-rpc\n\n# REST RPC for TypeScript\n\nThis library allows you to define your RESTful API in a TypeScript interface. \nThat interface definition could be share between your backend and frontend code bases.\nFrom that interface library can generate client and server stubs.\n\nUses `Koa.JS` for server stubs and `Fetch` to make client requests.\n\n## Example\n\n### Installation\n\n```\nyarn add typescript-rest-rpc\n```\n\n### Code\nshared.ts:\n```\nexport interface Backend {\n    login({ username, password }): Promise\u003c{ token: string }\u003e\n}\n\n```\n\nserver.ts:\n```\nimport { createServerRouter } from \"typescript-rest-rpc/lib/server\"\n\nclass BackendImpl implements Backend {\n    async login({ username, password }): Promise\u003c{ token: string }\u003e {\n        if (username == \"admin\" \u0026\u0026 password == \"123456\")\n            return { token: \"ok\" }\n\n        throw new BadRequest(\"Invalid login or password\")\n    }\n}\n\nconst backendRouter = createServerRouter(\"/api\", new BackendImpl())\napp.use(backendRouter.routes())\n```\n\nclient.ts:\n\n```\nimport { createClient } from \"typescript-rest-rpc/lib/client\"\n\nconst client: Backend = createClient(\"http://localhost:9090/api\")\nconsole.log(await client.login({ username: \"admin\", password: \"123456\" }))\n```\n\nWith this code you can even Ctrl-Click from your client code to your backend \nimplementation to quick find how API is implemented! \n\n## Features\n- Generating client and server RPC proxies based on zero-config TS interface.\n- File upload support via multipart encoding (uses `koa-multer` under the hood).\n- Binary data download.\n- JSON bodies auto-parsing with Date revival. \n- Supported client envs: Node.JS (with `isomorphic-fetch`), browser, react-native(see notes).\n- Generation of OpenAPI (Swagger) YAMLs with API description\n \n## Implementation flaws\n- untyped File in Multipart definition\n- untyped File in binary download\n- ctx parameter is untyped and should be defined in the base interface\n\n\n## Notes on the implementation\n\n### React-Native clients\n\nFor generating clients ES6 Proxy is used. However, React-Native doesn't support ES6 proxy \non some devices, see [this RN Issue](https://github.com/facebook/react-native/issues/11232#issuecomment-264100958]).\nAnd no polyfills could exist that will handle dynamic properties. So for React Native you \nshould explicitly list your interface operations:\n```\nexport let backend: Backend = createClient(url, { ... }, \n    [ \"login\", \"resetPassword\", etc ]\n)\n``` \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvasyas%2Ftypescript-rest-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvasyas%2Ftypescript-rest-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvasyas%2Ftypescript-rest-rpc/lists"}