function registerQARoutes(app, { qa }) {
  app.get('/api/qa-checks/:divisionId', (req, res) => {
    res.json({ checks: qa.listQaChecks(Number(req.params.divisionId) || 5) });
  });

  app.post('/api/qa-checks', (req, res) => {
    const id = qa.insertQaCheck(req.body || {});
    res.json({ id });
  });

  app.put('/api/qa-checks/:id', (req, res) => {
    const success = qa.updateQaCheck(Number(req.params.id), req.body || {});
    if (!success) return res.status(404).json({ error: 'QA check not found' });
    res.json({ success: true });
  });

  app.delete('/api/qa-checks/:id', (req, res) => {
    qa.deleteQaCheck(Number(req.params.id));
    res.json({ success: true });
  });

  app.get('/api/release-gates/:divisionId', (req, res) => {
    res.json({ gates: qa.listReleaseGates(Number(req.params.divisionId) || 5) });
  });

  app.post('/api/release-gates', (req, res) => {
    const id = qa.insertReleaseGate(req.body || {});
    res.json({ id });
  });

  app.put('/api/release-gates/:id', (req, res) => {
    const success = qa.updateReleaseGate(Number(req.params.id), req.body || {});
    if (!success) return res.status(404).json({ error: 'Release gate not found' });
    res.json({ success: true });
  });

  app.delete('/api/release-gates/:id', (req, res) => {
    qa.deleteReleaseGate(Number(req.params.id));
    res.json({ success: true });
  });
}

module.exports = { registerQARoutes };
