I want to create an endpoint that sends back the content of a file using sendFile. Writing the route on my own in my Express application, I know what to do and it works:
app.get('/api/logs', (req, res) => {
var path = require('path');
res.sendFile(path.join(__dirname, '../../../..', 'file.log'));
});
But since I am using tsoa, I need to write these in my controller which I would do like this:
@Route('getlogs')
export class LoggerController extends Controller {
@Get()
async getLogs(@Response("") res: express.Response) {
let filePath = path.join(__dirname, '../../../..', 'file.log');
res.sendFile(filePath);
return res;
}
}
but doing so, I am running in the following error:
Generate routes error.
Error: Multiple matching models found for referenced type Response; please make model names unique.
This is true. I have a model for Response in node_modules/aws-sdk and in node_modules/@types. So I imagine maybe I should not use express.Response in this setup. It should not be that hard to do this.
If someone has an idea how to handle this, I would be very glad.