As I've figured it out with your help (thank you again for bearing with me 😄 ) in #492, one can accept streams using content type parser, i.e.:
fastify.addContentTypeParser('*', function (req, done) {
var data = ''
req.on('data', chunk => { data += chunk })
req.on('end', () => {
done(data)
})
})
My question is - is it possible to pipe request stream into something? E.g. in express/hapi/micro/etc one can do something like this:
// init project
var express = require('express');
var app = express();
// http://expressjs.com/en/starter/basic-routing.html
app.post("/", function (request, response) {
request.pipe(response);
});
// listen for requests :)
var listener = app.listen(process.env.PORT, function () {
console.log('Your app is listening on port ' + listener.address().port);
});
And when sending POST request to / you'll get your body as a response.
Is it possible to do this with fastify? (not speaking about piping request to response, but rather piping request to other useful libs)
As I've figured it out with your help (thank you again for bearing with me 😄 ) in #492, one can accept streams using content type parser, i.e.:
My question is - is it possible to pipe request stream into something? E.g. in express/hapi/micro/etc one can do something like this:
And when sending POST request to
/you'll get your body as a response.Is it possible to do this with fastify? (not speaking about piping request to response, but rather piping request to other useful libs)