New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jsonrpc-ts

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonrpc-ts

Strongly Typed Fast and lightweight JSON RPC 2.0 Client for Nodejs

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
729
decreased by-15.33%
Maintainers
1
Weekly downloads
 
Created
Source

JSONRPC Typescript

Build Status Greenkeeper badge Coverage Status

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

todo: Add NPM install Here

Usage

First you need to define your Methods, that could be achieved by creating an interface of methods name and there parameters.

// we have a service that can do math,
// and it has this methods
interface MathService {
    // a method called sum that accepts 2 args of type number
    sum: [number, number];
    // methods can have named paramerter too.
    sub: { left: number, right: number };
}

then import RpcClient and start making requests

import { RpcClient } from 'jsonrpc-ts';

const rpcClient = new RpcClient<MathService>({ url: '...' });
// now you have a strongly typed methods.
// try to change [3, 2] to ['3', '2'] and the typescript compiler will catch you !
const response = await rpcClient.makeRequest({ method: 'sum', params: [3, 2], id: 1, jsonrpc: '2.0' });
// response.data.result === 5

TODO: Add API Docs Here !

FAQs

Package last updated on 05 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc