To stream files in Node Express to client, we create a read stream and pipe it.
For instance, we write
app.use((req, res, next) => {
if (req.url === "somethingorAnother") {
res.setHeader("content-type", "some/type");
fs.createReadStream("./toSomeFile").pipe(res);
} else {
next();
}
});
to call createReadStream to create a read stream to read toSomeFile.
And we call pipe with res to pipe the read stream as the response.