What's the proper way to return stream from Firebase callable function? I want it to behave like a proxy and return the response stream directly. Currently, I wait for response and append them like shown below. I don't think it's the right way to do it as it won't return stream directly.
const axios = require('axios');
const functions = require("firebase-functions");
const {PassThrough} = require("stream");
exports.create = functions.https.onCall(async(data, context) => {
const options = {
method: 'POST',
url: '...someurl',
,
responseType: 'stream'
};
const response = await axios(options)
const chunks = response.data.pipe(new PassThrough({encoding:'base64'}));
// then we use an async generator to read the chunks
let str = '';
for await (let chunk of chunks) {
str += chunk;
}
return str;
}