node package manager


Simple RPC. Call node functions from the browser.

Using with connect

On the Server

rpc = new require('minirpc').RPC

# simple
rpc.sum = (a, b) -> a + b

# you can access current HTTP request ( available as rpc._request )
rpc.get_header = (header_name) ->

# async? no problem, just return a function that takes a callback(res, err) as argument
rpc.get_weather = ( zip_code ) -> 
  ( cb ) ->
    some_remote_service zip_code, true, (res) -> cb res

# if you're using express/connect
app.use rpc._middleware()

On The Client

<!-- Will dynamically create proxies for every method attached to rpc -->
<script src="/___rpc.js"></script>
  ___rpc.sum 1, 2, (res) ->
    console.log "1 + 2 = #{res}"


I have not released this as an NPM module yet because it is under heavy development. So the only way to use this is by getting source and linking via NPM link. The following will do the trick. mkdir -p /usr/src cd /usr/src git clone git:// cd minirpc npm link .

Error handling