remote-ex

Node JS RPC

npm install remote-ex
4 downloads in the last week
7 downloads in the last month

rex

Minimal Node JS rpc with wide browser coverage

Bug fixes welcome

Server

var 

express = require('express'),
app = express();
app.use(express.bodyParser());

api = {
        servertime: function(){
            return Date();
        },
        echo: function(o, req, res){
            return {echo: o};
        }
};

app.get('/', function(r, s, n){
    s.end('<script src="rex.js"></script> Open Console and try rex.servertime() or rex.echo("a=1&b=2")');
})

require('../rex.js')(api, app);
app.listen(8080);

Client

<script src="rex.js"></script>
<script>
   // rex.servertime();
   // rex.echo('a=1&b=2');
   // rex.echo({a: 1, b: 2});
</script>

Rex lets you call server functions from the browser. It has minimal footprint and works with express web server, or other web servers that implement .get(), .post(), and req.params, for instance clarity.

The example above should explain things. Rex generates the client JS and you call rex functions from the browser with a parameter and callback.

  // in client JS
  rex.servertime();
  rex.echo('a=1&b=2', function(resp){
      ...
  })
  rex.echo({a: 1, b: 2}, function(resp){
      ...
  })

Use Curl

$ curl --data "" servername/rex/servertime
$ curl --data "q=1" servername/rex/echo
  => {echo: {"q":"1"}}

Why?

Page sizes, frameworks have gone nuts in size and browser load to do simple things. Rex handles the RPC in a minimal footprint, without frameworks, and is simple to use. Rex uses only xmlhttp and POST, for maximum browser coverage, and may be especially useful for mobile devices or limited resource environments.

npm loves you