straggler

aggregate text streams

straggler

aggregate text streams

api example

First generate keypairs for your hub, viewer, and writer rsa-json:

$ rsa-json > hub.json
$ rsa-json > viewer.json
$ rsa-json > writer.json

Create a hub and bind it to an http server:

var straggler = require('straggler');
var st = straggler(require('./hub.json'));
var hub = st.createHub(require('./authorized.json'));
 
var http = require('http');
var server = http.createServer(function (reqres) {
    hub.handle(req, res);
});
server.listen(5000);

Write a viewer.js program to read messages from the writer:

var straggler = require('straggler');
var st = straggler(require('./viewer.json'));
var read = st.read('http://localhost:5000');
read('writer').pipe(process.stdout);

Write a writer.js program to write messages to the hub:

var straggler = require('straggler');
var st = straggler(require('./writer.json'));
var w = st.write('http://localhost:5000');
w.end('beep boop\n');

Run the hub, the viewer, and the writer programs:

$ node hub.js &
[1] 18835
$ node viewer.js &
[2] 18840
$ node writer.js
beep boop

methods

var straggler = require('straggler')

Create a new stragger instance st from keys, a public/private keypair generated by rsa-json.

Handle a request from a (req, res) pair from an http server.

Test a req.url string, returning the handler that should fire or undefined if the route doesn't match anything.

Return a function reader to create named streams.

cb(err, keys) fires with keys, and object that maps public key strings to the user objects set up by createHub().

Close the connection to the hub.

Return a readable stream of data from the writer given by name.

Return a writable stream of data from the writer given by name.

attributes

populated with the authorized key data from createHub(authorized) after the connection is established

install

With npm do:

npm install straggler

license

MIT