Client with http Trasport
import { createHttpRpcClient } from 'json-rpc2.0-node'
const client = createHttpRpcClient('http://endpoint',{Authorization:"token or other headers, or other http header"})
const res = await client.invoke('method','param1','param2')
client.notify('method','param1','param2')
const t:T = client.as<T>()
t.method('param1','param2')
Client with custom Trasport
import { Client,Trasport } from 'json-rpc2.0-node'
function Mytransport(json:string){
return Promise.resolve()
}
const client = new Client(Mytransport)
Server
import { Server } from 'json-rpc2.0-node'
const server = new Server()
server.expose('hello', () => 'hello world!')
const jsonbody = `
{
"id":10,
"method":"hello",
"jsonrpc":"2.0"
}
`
const jsonrpcResponse = await server.handle(jsonbody)
see more help in src/tests