You don’t need a readable stream instance, just use res.write()
:
res.write("USERID,NAME,FBID,ACCOUNT,SUBSCRIPTION,PRICE,STATE,TIMEPERIOD\n");
for (var i = 0; i < 10; i++) {
res.write("23,John Doe,1234,500,SUBSCRIPITON,100,ACTIVE,30\n");
}
res.end();
This works because in Express, res
is based on Node’s own http.serverResponse
, so it inherits all its methods (like write
).