Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/webeetle/jrpc-client
JRPC-Client is a simple JSON-RPC 2.0 client for node.js and browser, developed in typescript for work synergy with JRPC-Server.
https://github.com/webeetle/jrpc-client
json json-api json-rpc json-schema typescript
Last synced: 24 days ago
JSON representation
JRPC-Client is a simple JSON-RPC 2.0 client for node.js and browser, developed in typescript for work synergy with JRPC-Server.
- Host: GitHub
- URL: https://github.com/webeetle/jrpc-client
- Owner: webeetle
- License: mit
- Created: 2023-05-12T07:43:18.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-05-19T08:23:10.000Z (over 1 year ago)
- Last Synced: 2024-04-24T21:00:46.032Z (7 months ago)
- Topics: json, json-api, json-rpc, json-schema, typescript
- Language: TypeScript
- Homepage:
- Size: 112 KB
- Stars: 1
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# JRPC-Client
JRPC-Client is a simple JSON-RPC 2.0 client for node.js and browser, developed in typescript for work synergy with [JRPC-Server](https://github.com/webeetle/JRPC-Server).
## Install
```bash
npm i @habeetat/jrpc-client
```## Todo
- [ ] Test
- [ ] Documentation
- [ ] Enable test in github action## How to use
```typescript
export interface TestServerRpcMethods {
/**
* say hi
*/
hi(person: { name: string, bithday: Date }): Promise;/**
* sum two numbers
*/
sum(a: number, b: number): Promise;/**
* get all todos
*/
getTodos(): Promise<{ id: number, text: string, completed: boolean }[]>;
}(async () => {
const resolver = async (url: string, data: string, resolve: (result: any) => void) => {
console.log(`send to ${url} data ${data}`);
};
const client = new RpcClient("http://localhost:3000/rpc", resolver);
const proxy = client.createProxy();
const result = await proxy.hi({ name: "John", bithday: new Date() });
})();
```