Call functions on node server from browser web UI for quick prototyping
JavaScript
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE.md
README.md
client.js
globalServerStub.js
index.js
package.json
run.js

README.md

remote-control

Call functions on NodeJS server directly from client-side code in the browser UI for quick prototyping and local deployments. Use promises to get return value. Supports server push (by wrapping readable streams returned by server code).

If you are quickly prototyping a new app with both in-browser and server-side components, the last thing you want to worry about is setting up Express routes, the main entry-point HTML file, encoding/decoding values, dealing with XHR... This module is designed to help get going without all the boilerplate, as just a simple live "tunnel" between the browser and server worlds.

The easiest way to get started is to just install as a global utility:

npm install -g remote-control

Then put client-side in index.js:

var server = require('__server')(); // Browserified by default, but that's optional

server.helloWorld('foo value', 'bar value').then(function (baz) {
    document.body.appendChild(
        document.createTextNode('responded with: ' + baz)
    );
});

And server-side code in server.js:

module.exports = {
    helloWorld: function (foo, bar) {
        console.log('invoked helloWorld with', foo, 'and', bar);

        return 'baz value';
    }
};

Then run:

remote-control server.js index.js

And open http://localhost:3000/ in your browser. That's it!

The remote-control utility is a sandbox development server. It automatically browserifies the client-side code and presents it to the browser inside a ready-made page. It works much like the excellent Beefy runner, but adds the necessary plumbing to directly call functions server-side.

To Do

  • document Express middleware mode
  • implement connection restart
  • document server push features
  • extend server push features? add time out as well
  • allow auto-reloading code
  • add code checksumming?