How would you go to create a streaming API with Node? just like the Twitter streaming API.
What I want to do ultimately is get the first update from the FriendFeed api, and stream when a new one becomes available (if the id is different), and later on expose it as a web service so I can use it with WebSockets on my website :).
So far I have this:
var sys = require('sys'), http = require('http');var ff = http.createClient(80, 'friendfeed-api.com');var request = ff.request('GET', '/v2/feed/igorgue?num=1', {'host': 'friendfeed-api.com'});request.addListener('response', function (response) { response.setEncoding('utf8'); // this is *very* important! response.addListener('data', function (chunk) { var data = JSON.parse(chunk); sys.puts(data.entries[0].body); });});request.end();
Which only gets the data from FriendFeed, creating the Http server with node is easy but it can't return a stream (or I haven't yet found out how).