New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@ctx-core/rpc

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ctx-core/rpc

ctx-core rpc

latest
Source
npmnpm
Version
3.1.0
Version published
Maintainers
1
Created
Source

RPC

This package is dormant & stripped of functionality, due to ctx-core moving away from Agent objects & using Store instead.

A Remote Procedure Call (rpc) mechanism.

rpc provides an api which exposes functions as a service, while wrapping operations to run auth & whitelist public data.

Since rpc maps to functions, rpc can be a technique of modularizing & composing server code.

Why not just use REST?

In this rpc architecture, REST is used to access call__rpc via POST /rpc in ctx-core/rpc/koa.

rpc is a more primitive network protocol, allowing functions to be directly called.

These same functions may also be wrapped in a RESTful resource.

This of this as composable controller functions or a layer under koa http handlers.

Multiple rpc calls may be invoked & run in parallel or in sequence using a simple functional interface.

Representing a RESTful api as rpc (RESTful prototypes & Refactoring)

With a naming convention, you can depict a RESTful request using a simple function.

get__quovo__account__portfolios simulates GET https://api.quovo.com/v2/accounts/:account_id/portfolios on the server.

Refactoring these methods provides a lightweight way to discover the appropriate RESTful endpoints.

Server

A rpc is run on the server using run__rpc in ctx-core/rpc/lib.

RESTful (koa) request handlers can run__rpc to reuse code & get the benefits of rpc services.

Client

Client Request

A rpc is called on the client via a HTTP POST /rpc accepting json:

{
	"rpc": ["rpc1", "rpc2", "rpc3"],
	"authentication": "{string|Object}",
	"sample_key_1": "sample_value_1",
	"sample_key_2": "sample_value_2",
	"sample_key_3": "sample_value_3"
}

The rpc array calls are run in parallel on the first dimension of the array.

The data in the json may set the rpc ctx after being filtered through the run__rpc whitelist in ctx-core/rpc/lib.

In the future, a second dimension may be added to run those rpc calls in sequence.

Client Response

A successful response will by the ctx to be handled by the client.

Keywords

ctx-core

FAQs

Package last updated on 23 Nov 2019

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