Last active
August 29, 2015 14:25
-
-
Save Marak/9c72054e6e0b42ba69b3 to your computer and use it in GitHub Desktop.
hook.io example microservice for merging streaming together
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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