I'm trying to pipe Express request object to a writable stream. NodeJS creates a file, but it's empty. What am I missing?
var express = require('express');
var fs = require('fs');
var app = express();
    app.use(middleWare);
    app.listen(3000);
function middleWare(req, res, next){
    var ws = fs.createWriteStream('./test.txt');
    req.pipe(ws);
    res.sendStatus(200);
}
When I replace req.pipe(ws) with ws.write(req) I get an error:
 TypeError: Invalid non-string/buffer chunk
When I replace ws.write(req) with ws.write(JSON.stringify(req)) I get an error:
  TypeError: Converting circular structure to JSON
 
     
    