Code Room
Code reviewMedium
Question
Review this Express invoice download endpoint.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
app.get('/api/invoices/:id/pdf', requireLogin, async (req, res) => { const invoice = await db.invoice.findUnique({ where: { id: req.params.id }, }); if (!invoice) return res.status(404).send('not found'); const pdf = await renderInvoicePdf(invoice); res.type('application/pdf').send(pdf);});Run or narrate your approach, then ask the coach.