Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frankwallis/jrpc2-proxy
Auto-generate client-side proxy objects and functions for jrpc2
https://github.com/frankwallis/jrpc2-proxy
Last synced: 10 days ago
JSON representation
Auto-generate client-side proxy objects and functions for jrpc2
- Host: GitHub
- URL: https://github.com/frankwallis/jrpc2-proxy
- Owner: frankwallis
- License: mit
- Created: 2015-09-13T01:05:44.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-13T09:40:54.000Z (over 9 years ago)
- Last Synced: 2024-04-26T01:03:52.652Z (9 months ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jrpc2-proxy
Auto-generate client-side proxy objects and functions for [jrpc2](https://github.com/Santinell/jrpc2)
[![build status](https://secure.travis-ci.org/frankwallis/jrpc2-proxy.png?branch=master)](http://travis-ci.org/frankwallis/jrpc2-proxy)
## Examples
### Services
```
var rpc = require('jrpc2');
var proxy = require("jrpc2-proxy");
var AjaxTransport = require("jrpc2-ajax");
var transport = new AjaxTransport({path: "/api/"});
var client = new rpc.Client(transport);
var userService = proxy.createService(client, ["fetchUsers", "getUser"]);userService.fetchUsers()
.then(...);userService.fetchUsers(function(err, users) {
...
});userService.getUser(id)
.then(...)userService.getUser(id, function(err, user) {
...
})
```### Functions
```
var loadPosts = proxy.createFunction(client, "loadPosts");
loadPosts(queryParams).then(...etc);
```## TODO
- Support ES6 proxies
- Create proxy from remote schema