diff --git a/routes/calendar.cts b/routes/calendar.cts index 5cab533..5795d1a 100644 --- a/routes/calendar.cts +++ b/routes/calendar.cts @@ -1,7 +1,7 @@ // @ts-nocheck — route controller converted to .cts; handler req/res typed, full type-check deferred (thin glue over typed services). import type { Req, Res, Next } from '../types/http'; const express = require('express'); -const { standardizeError } = require('../middleware/errorFormatter.cts'); +const { ValidationError } = require('../utils/apiError.cts'); const router = express.Router(); const { getDb } = require('../db/database.cts'); const { buildTrackerRow, getCycleRange } = require('../services/statusService.cts'); @@ -104,22 +104,10 @@ router.get('/', (req: Req, res: Res) => { const month = parseInt(req.query.month || now.getMonth() + 1, 10); if (isNaN(year) || year < 2000 || year > 2100) { - return res - .status(400) - .json( - standardizeError( - 'year must be a 4-digit integer between 2000 and 2100', - 'VALIDATION_ERROR', - 'year', - ), - ); + throw ValidationError('year must be a 4-digit integer between 2000 and 2100', 'year'); } if (isNaN(month) || month < 1 || month > 12) { - return res - .status(400) - .json( - standardizeError('month must be an integer between 1 and 12', 'VALIDATION_ERROR', 'month'), - ); + throw ValidationError('month must be an integer between 1 and 12', 'month'); } const today = localDateString(now);