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

rpcinterface

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rpcinterface

Library that facilitates an RPC interface in a webapp or node app

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

rpcinterface

Build a rpc interface in your webapp or node app. Requires jQuery for promises on the web (via browserify).

Usage (with browserify/node)

var rpc = require('rpcinterface');

RPCInterface Methods

rpc = new RPCInterface()

Creates a new RPCInterface instance. Should be done at application start up.

rpc.addMethod(name, params, handler)

rpc.addMethod(name, handler)

rpc.addMethod(name, options)

Adds a new handler for method name. options should be an object that has handler and params keys. handler is a callback that is called with (parameters, deferred) when a new call is made for this method name. If params are not defined then no parameter checking is done.

params should be a hash like this example:

{
    email: {type: 'string', optional: false},
    password: {type: 'string', optional: false},
    name: {type: 'string', optional: false},
    phone: {type: 'number', optional: true}
}

If params is null (rather than an object or undefined) then the parameters object sent to the handler will be an empty object, guaranteed. Normally the passed object is validated but passed through as originally sent. This could cause issues if you're expecting an empty object since your method accepts no parameters but the caller sent extraneous parameters.

rpc.removeMethod(name)

Removes the handler for method name.

rpc.setPreProcessor(func)

Sets the pre-processor, which is called before the handler but after the request is validated. The func is sent (method, params, dfd). method is the string method name being called and params is the parameters object sent by the caller.

rpc.call(method[, params])

Calls a method added by addMethod and sends along the passed params. Returns a deferred. Throws if params are invalid/missing for the method being called or if the method wasn't added. params can also be an array where the order of the values is based on the defined order when addMethod was called.

Keywords

rpc

FAQs

Package last updated on 11 Sep 2015

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