function registerHistoryRoutes(app, { workflowHistory }) {
  app.get('/api/board/history', (req, res) => {
    const fromDate = req.query?.from;
    const toDate = req.query?.to || fromDate;
    res.json(workflowHistory.getBoardSnapshot({ fromDate, toDate }));
  });

  app.put('/api/items/:id/meta', (req, res) => {
    const updated = workflowHistory.updateItemMeta(Number(req.params.id), req.body || {});
    if (!updated) return res.status(404).json({ error: 'Workflow not found' });
    res.json({ success: true, item: updated });
  });

  app.put('/api/todos/:id', (req, res) => {
    const updated = workflowHistory.updateTodoMeta(Number(req.params.id), req.body || {});
    if (!updated) return res.status(404).json({ error: 'Task not found' });
    res.json({ success: true, todo: updated });
  });
}

module.exports = { registerHistoryRoutes };
