Jrus
Jrus is a server-client communication utility package, which facilitates seamless remote procedure call.
The communication protocol Jrus uses is jsonrpc 2.0.
Install
npm i jrus
Quick Start
Server side
; // create a new server instanceconst server = ; // register a serviceserver; // run and listen on port 3000server;
Client side
; // create a client and connect http://localhost:3000const client = 'http://localhost:3000'; async { // remote procedure call: Utility.time console; // 018-03-31T15:54:37.568Z // remote procedure call: Utility.sayHi, with parameters { name: 'Special Name' } console; // { say: 'hello, Special Name ' } // remote procedure call: Utility.wrong; and cathc error thrown on the server side try await clientservicesUtility; catch e console; // Error caught: JrusError { code: 10056, message: 'sample error' } // call some function nonexist: Utility.right try await clientservicesUtilityright; catch e console; // Error caught: JrusError { code: -32601, message: 'Method not found' } };