Minimalistic Grenache HTTP implementation for the browser.
Aim is to have full browser compatability with the smallest amounts of deps as possible, to reduce file sizes for the frontend.
To use Grenache in the Browser, CORS headers must be set by a proxy (e.g. haproxy or nginx). In dev mode, we use express.
const { Link, PeerRPCClient } = require('grenache-browser')
const link = new Link({
grape: 'http://127.0.0.1:1337'
}).start()
const peer = new PeerRPCClient(link, { ssl: false })
peer.init()
const opts = { timeout: 100000 }
peer.request('rpc_test', { hello: 'world' }, opts, (err, res) => {
console.log(err, res)
})
cd example
node dev.js
opts <Object>
Options for the linkgrape <String>
Address of the Grenache Grape instancerequestTimeout <Number>
Default timeout for requests to Grape network
Sets up the link for usage.
Stops the link.
opts <Object>
Options for the linkrequestTimeout <Number>
Default timeout for requests to Grape networkssl
Use SSL protocol
Starts the client.
opts <Object>
Options for the linktimeout <Number>
Timeout for request