const express = require('express');
const router = express.Router();
const { standardizeError } = require('../middleware/errorFormatter');
const { getAnalyticsSummary } = require('../services/analyticsService');

router.get('/summary', (req, res) => {
  const result = getAnalyticsSummary(req.user.id, req.query);
  if (result.error) return res.status(400).json(standardizeError(result.error, 'VALIDATION_ERROR', 'month'));
  res.json(result);
});

module.exports = router;
