Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Really simple Browser-->Server RPC for Node.js
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
README.md
index.js
package.json

README.md

THIS MODULE IS OLD AND DEPRECATED. I RECOMMEND YOU USE AN ALTERNATIVE SUCH AS https://github.com/substack/dnode


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) ->
  rpc._request.headers[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 null, 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="/___minirpc.js"></script>
<script>
  ___minirpc.sum 1, 2, (res) ->
    console.log "1 + 2 = #{res}"
</script>

Installation

npm install minirpc

Error handling

Related

http://groups.google.com/group/json-rpc/web/json-rpc-2-0

Changelog

0.0.2

Something went wrong with that request. Please try again.