rfunc
Remote function call with async interface
Installation
$ npm install rfunc --save
Usage
Define functions on server side.
#!/usr/bin/env node /** * This is an example to invoke rfunc server */'use strict' const rfunc = void { // Setup server for remote call await }
rfunc client create the function dynamically on client side and you can just call it.
#!/usr/bin/env node /** * This is an example of rfunc client */'use strict' const rclient = void { const sign = await // Define a client // Call remote api and receive the result const success = await sign console}
Advanced Usage
To be more specific about api, provide $spec
on server side.
#!/usr/bin/env node /** * Advanced usage of the server */'use strict' const rfunc = const http = void { const server = http // Apply to existing http server server}
Then you can fetch the spec data via .describe()
method on client side.
#!/usr/bin/env node /** * This is an example of rfunc client */'use strict' const rclient = void { let sign = await // Fetch the spec data let $spec = await sign /* ... */}
This cloud be useful to generate API documentations.
License
This software is released under the MIT License.