https://github.com/ahuangege/i-http-rpc
a http rpc
https://github.com/ahuangege/i-http-rpc
http-rpc json-rpc rpc rpc-framework
Last synced: 26 days ago
JSON representation
a http rpc
- Host: GitHub
- URL: https://github.com/ahuangege/i-http-rpc
- Owner: ahuangege
- Created: 2022-09-08T08:08:18.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-03T02:12:35.000Z (over 3 years ago)
- Last Synced: 2025-09-06T19:24:07.966Z (11 months ago)
- Topics: http-rpc, json-rpc, rpc, rpc-framework
- Language: TypeScript
- Homepage:
- Size: 10.7 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# i-http-rpc
一个带智能提示的 http rpc
# Install
```bash
npm i i-http-rpc
```
# Usage
```
import { createHttpRpcClient, createHttpRpcServer, I_httpRpcClient } from "i-http-rpc";
let port = 3000;
class MyMath {
add(a: number, b: number) {
return a + b;
}
}
interface RpcDemo {
math: MyMath
}
createHttpRpcServer({
"port": port,
"handlers": {
"math": new MyMath()
}
});
let client: I_httpRpcClient = createHttpRpcClient({ "url": `http:127.0.0.1:${port}` });
async function test() {
let res = await client.rpc().math.add(1, 2);
console.log(res)
}
test();
```