JSONRPC Typescript

Strongly 💪 Typed JSON RPC 2.0 Client for Nodejs
Fully tested to comply with the official JSON-RPC 2.0 specification
Quick Overview
By Declaring events using a simple interface mapping methods names to their parameters to get Strongly Typed, Fast and Modern Rpc client for your service.
Install
npm i jsonrpc-ts
Usage
First you need to define your Methods, that could be achieved by creating an interface of methods name and there parameters.
interface MathService {
sum: [number, number];
sub: { left: number; right: number };
sumWithReturnType: ({ x, y }: { x: number; y: number }) => number;
}
then import RpcClient
and start making requests
import { RpcClient } from 'jsonrpc-ts';
const rpcClient = new RpcClient<MathService>({ url: '...' });
const response = await rpcClient.makeRequest({
method: 'sum',
params: [3, 2],
id: 1,
jsonrpc: '2.0',
});
const response2 = await rpcClient.makeRequest({
method: 'sumWithReturnType',
params: { x: 3, y: 2 },
id: 2,
jsonrpc: '2.0',
});