refactor(routes/calendar): replace errorFormatter with ValidationError throws
This commit is contained in:
parent
e9f52b7472
commit
bdff5ad932
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue