Skip to content

Instantly share code, notes, and snippets.

@Marak
Last active August 29, 2015 14:25
Show Gist options
  • Save Marak/9c72054e6e0b42ba69b3 to your computer and use it in GitHub Desktop.
Save Marak/9c72054e6e0b42ba69b3 to your computer and use it in GitHub Desktop.
hook.io example microservice for merging streaming together
module['exports'] = function mergeStreams (hook) {
var ms = require('merge-stream');
var stream1 = hook.open('https://hook.io/Marak/examples-helloWorld');
var stream2 = hook.open('https://hook.io/Marak/examples-helloWorld');
var merged = ms(stream1, stream2);
// You can also add new streams later
// merged.add(stream3);
merged.on('data', function(chunk){
hook.res.write(chunk.toString());
});
merged.on('end', function(){
hook.res.end();
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment