Code Room
Code reviewMedium
Question
Review this TypeScript pagination 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
// GET /orders?page=1&limit=20router.get('/orders', async (req, res) => { const page = Number(req.query.page) || 1; const limit = Number(req.query.limit) || 20; const offset = (page - 1) * limit; const rows = await db.query( 'SELECT * FROM orders WHERE user_id = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3', [req.user.id, limit, offset] ); res.json({ orders: rows, page, limit });});Run or narrate your approach, then ask the coach.