I make single page applications with Angular that use Meteor as a pure backend, no routing in Meteor, just using methods over DDP.
I need to add the possibility to download content files (pdf, csv, etc.) that are dynamically generated on the server. I also need to be able to check who the user is and if he is authenticated.
I found this mhagmajer:server-router which seems to do what I need. But it seems that is is not very widely used, although I think that what I need would be fairly common use case.
Is there a more common way to to this?
for clarity
What I want to do would be done in express.js like this:
router.post(’/pdf’, (req, res, next) => {
res.setHeader(‘Content-disposition’, ‘inline; filename="’ + req.filename + ‘"’);
res.setHeader(‘Content-type’, ‘application/pdf’);
pdf.create(req.pdfHtml, req.pdfOptions).toStream(function (err, stream) {
if (err) {
next(err);
} else {
stream.pipe(res);
}
});
});