i-http-rpc
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

i-http-rpc

一个带智能提示的 http rpc

Install

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<RpcDemo>({
    "port": port,
    "handlers": {
        "math": new MyMath()
    }
});

let client: I_httpRpcClient<RpcDemo> = createHttpRpcClient({ "url": `http:127.0.0.1:${port}` });
async function test() {
    let res = await client.rpc().math.add(1, 2);
    console.log(res)
}
test();

Readme

Keywords

Package Sidebar

Install

npm i i-http-rpc

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

29.2 kB

Total Files

9

Last publish

Collaborators

  • ahuang