I have a controller method in my inversify-express-utils app that looks something like this:
return await this.downloadReportUseCase.invoke(String(req.query.report_id), String(req.query.user_id))
.then(async ([filename, filedata]: [string, string]) => {
return res.status(200).sendFile(fs.writeFileSync(filename, filedata)); // I want to do something like this
})
.catch((err: Error) => {
res.status(500).json(err);
});
Note the comment, how do i achieve something like that? I don't actually want to create a file on the server, i just want a the variable to be sent to the end user in the form of a file that is either XML or CSV file type.