function registerProductionRoutes(app, { production }) {
  app.get('/api/production-assets/:divisionId', (req, res) => {
    res.json({ assets: production.listProductionAssets(Number(req.params.divisionId) || 4) });
  });

  app.post('/api/production-assets', (req, res) => {
    const id = production.insertProductionAsset(req.body || {});
    res.json({ id });
  });

  app.put('/api/production-assets/:id', (req, res) => {
    const success = production.updateProductionAsset(Number(req.params.id), req.body || {});
    if (!success) return res.status(404).json({ error: 'Production asset not found' });
    res.json({ success: true });
  });

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

  app.get('/api/staging-runs/:divisionId', (req, res) => {
    res.json({ runs: production.listStagingRuns(Number(req.params.divisionId) || 4) });
  });

  app.post('/api/staging-runs', (req, res) => {
    const id = production.insertStagingRun(req.body || {});
    res.json({ id });
  });

  app.put('/api/staging-runs/:id', (req, res) => {
    const success = production.updateStagingRun(Number(req.params.id), req.body || {});
    if (!success) return res.status(404).json({ error: 'Staging run not found' });
    res.json({ success: true });
  });

  app.delete('/api/staging-runs/:id', (req, res) => {
    production.deleteStagingRun(Number(req.params.id));
    res.json({ success: true });
  });

  app.get('/api/scope-controls/:divisionId', (req, res) => {
    res.json({ controls: production.listScopeControls(Number(req.params.divisionId) || 4) });
  });

  app.post('/api/scope-controls', (req, res) => {
    const id = production.insertScopeControl(req.body || {});
    res.json({ id });
  });

  app.put('/api/scope-controls/:id', (req, res) => {
    const success = production.updateScopeControl(Number(req.params.id), req.body || {});
    if (!success) return res.status(404).json({ error: 'Scope control not found' });
    res.json({ success: true });
  });

  app.delete('/api/scope-controls/:id', (req, res) => {
    production.deleteScopeControl(Number(req.params.id));
    res.json({ success: true });
  });
}

module.exports = { registerProductionRoutes };
