BillTracker/routes/analytics.cts

15 lines
589 B
TypeScript
Raw Permalink Normal View History

// Fully type-checked (tsconfig.server.json); leading import type keeps Node type-stripping active.
import type { Req, Res, Next } from '../types/http';
2026-05-04 13:14:32 -05:00
const express = require('express');
const router = express.Router();
const { ValidationError } = require('../utils/apiError.cts');
const { getAnalyticsSummary } = require('../services/analyticsService.cts');
2026-05-04 13:14:32 -05:00
router.get('/summary', (req: Req, res: Res) => {
2026-05-16 15:38:28 -05:00
const result = getAnalyticsSummary(req.user.id, req.query);
if (result.error) throw ValidationError(result.error, 'month');
2026-05-16 15:38:28 -05:00
res.json(result);
2026-05-04 13:14:32 -05:00
});
module.exports = router;