How would you write out the correct version of HTTP stream example with stream/promises pipeline, pass res as last parameter? And for fastify, reply.send?
use @fastify/static :). Don't stream files directly because there are infinite edge cases that will inevitably result in a security issues in your server.
Matteo Collina Thanks for the reply! Yes, understood for static files which can be directly served, but I was thinking more of the case when there is a pipeline - reading file then transforming and finally sending as a response...
Stasa Stanisic you can just call reply.send(stream) or return stream in your Fastify route. Using barebone HTTP, you should do pipeline(a, b, c, res, (err) => { ... }).