Code Room
Code reviewMediumcr-g131
Subject Pagination bugsLevel Mid–Senior~25 minCommon in Databases & SQL · Networking & APIs interviewsIndustries Software development

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.

Talk through your review
Code to reviewts
// 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.