dat-http-replicator
npm install dat-http-replicator
Usage
On a server
var replicator =var http =var server = httpserver
On a client
var replicator =var progress =progressprogressprogressprogress
API
progress = replicator.server(datGraph, req, res, [opts], [cb])
Setup a server http handler. Options include:
readonly: true // do not allow pusheswriteonly: true // do not allow pulls
Note that the progress monitor will be null
if this is an endpoint
without progress monitoring support.
progress = replicator.client(datGraph, url, [opts], [cb])
Make a replication request. Options include:
mode: 'push' | 'pull' | 'sync' // defaults to sync
Progress monitoring
The progress monitor returned will emit push
and pull
when you send a graph node
or receive a graph node. The progress events look like this
transferred: nodesTransferredSoFarlength: totalNumberOfNodesToTransfer
The latest progress event call also be accessed at progress.pushed
and progress.pulled