More information at https://metapointtech.github.io/metapoint/
import { h, MetaType, peer, z } from "metapoint";
// router group
const g = h();
// node1(nodejs/browser)
const node1 = await peer({
endpoint: {
numberAdd: g.handler({
func: async ({ data, send, done }) => {
await send(data + 1);
await done();
},
input: z.number(),
output: z.number(),
}),
},
});
export type meta = MetaType<typeof node1>;
// node2(nodejs/browser)
const node2 = await peer();
const channel = await node2.connect<meta>(node1.meta().addrs);
const add = await channel("numberAdd");
console.log(await add(1)); // [2]