refactor(types): drop @ts-nocheck from the 9 smallest routes (Phase 6 starter)
analytics, settings, tracker, about, calendarFeed, privacy, version, user, matches now fully type-checked by tsconfig.server.json. Fallout was 4 errors total: calendarFeed's res.set(object) -> per-header calls (+ the test mock now accepts both Express set() forms), and two error adapters gained parameter types. @ts-nocheck census: 38 -> 29 files; the B0 recon counter ratchets this down each cycle (QA-B0-04). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
a31a774f95
commit
db539545e3
|
|
@ -1,4 +1,4 @@
|
|||
// @ts-nocheck — route controller converted to .cts; handler req/res typed, full type-check deferred (thin glue over typed services).
|
||||
// Fully type-checked (tsconfig.server.json); leading import type keeps Node type-stripping active.
|
||||
import type { Req, Res, Next } from '../types/http';
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @ts-nocheck — route controller converted to .cts; handler req/res typed, full type-check deferred (thin glue over typed services).
|
||||
// Fully type-checked (tsconfig.server.json); leading import type keeps Node type-stripping active.
|
||||
import type { Req, Res, Next } from '../types/http';
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @ts-nocheck — route controller converted to .cts; handler req/res typed, full type-check deferred (thin glue over typed services).
|
||||
// Fully type-checked (tsconfig.server.json); leading import type keeps Node type-stripping active.
|
||||
import type { Req, Res, Next } from '../types/http';
|
||||
('use strict');
|
||||
|
||||
|
|
@ -25,11 +25,9 @@ router.get('/feed.ics', (req: Req, res: Res) => {
|
|||
markTokenUsed(tokenRow.id);
|
||||
|
||||
res.status(200);
|
||||
res.set({
|
||||
'Content-Type': 'text/calendar; charset=utf-8',
|
||||
'Content-Disposition': 'inline; filename="bill-tracker.ics"',
|
||||
'Cache-Control': 'private, max-age=300',
|
||||
});
|
||||
res.set('Content-Type', 'text/calendar; charset=utf-8');
|
||||
res.set('Content-Disposition', 'inline; filename="bill-tracker.ics"');
|
||||
res.set('Cache-Control', 'private, max-age=300');
|
||||
return res.send(ics);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @ts-nocheck — route controller converted to .cts; handler req/res typed, full type-check deferred (thin glue over typed services).
|
||||
// Fully type-checked (tsconfig.server.json); leading import type keeps Node type-stripping active.
|
||||
import type { Req, Res, Next } from '../types/http';
|
||||
const router = require('express').Router();
|
||||
const { getDb } = require('../db/database.cts');
|
||||
|
|
@ -23,7 +23,7 @@ const { todayLocal } = require('../utils/dates.mts');
|
|||
|
||||
// 4xx service errors keep their message/code on the wire; anything else is
|
||||
// rethrown raw so the terminal handler masks + logs it as a 5xx.
|
||||
function toMatchError(err) {
|
||||
function toMatchError(err: any) {
|
||||
if (err.status && err.status < 500) {
|
||||
return new ApiError(err.code || 'MATCH_ERROR', err.message, err.status, { field: err.field });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @ts-nocheck — route controller converted to .cts; handler req/res typed, full type-check deferred (thin glue over typed services).
|
||||
// Fully type-checked (tsconfig.server.json); leading import type keeps Node type-stripping active.
|
||||
import type { Req, Res, Next } from '../types/http';
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @ts-nocheck — route controller converted to .cts; handler req/res typed, full type-check deferred (thin glue over typed services).
|
||||
// Fully type-checked (tsconfig.server.json); leading import type keeps Node type-stripping active.
|
||||
import type { Req, Res, Next } from '../types/http';
|
||||
('use strict');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @ts-nocheck — route controller converted to .cts; handler req/res typed, full type-check deferred (thin glue over typed services).
|
||||
// Fully type-checked (tsconfig.server.json); leading import type keeps Node type-stripping active.
|
||||
import type { Req, Res, Next } from '../types/http';
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @ts-nocheck — route controller converted to .cts; handler req/res typed, full type-check deferred (thin glue over typed services).
|
||||
// Fully type-checked (tsconfig.server.json); leading import type keeps Node type-stripping active.
|
||||
import type { Req, Res, Next } from '../types/http';
|
||||
('use strict');
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ const { ApiError, ValidationError } = require('../utils/apiError.cts');
|
|||
|
||||
// 4xx service errors keep their message/code on the wire; anything else is
|
||||
// rethrown raw so the terminal handler masks + logs it as a 5xx.
|
||||
function toUserOpError(err, fallbackCode) {
|
||||
function toUserOpError(err: any, fallbackCode: string) {
|
||||
if (err.status && err.status < 500) {
|
||||
return new ApiError(err.code || fallbackCode, err.message, err.status);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @ts-nocheck — route controller converted to .cts; handler req/res typed, full type-check deferred (thin glue over typed services).
|
||||
// Fully type-checked (tsconfig.server.json); leading import type keeps Node type-stripping active.
|
||||
import type { Req, Res, Next } from '../types/http';
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
|
|
|||
|
|
@ -77,8 +77,10 @@ function callFeedRoute(query) {
|
|||
headers['Content-Type'] = value;
|
||||
return this;
|
||||
},
|
||||
set(values) {
|
||||
Object.assign(headers, values);
|
||||
set(field, value) {
|
||||
// Express supports both set(obj) and set(field, value)
|
||||
if (typeof field === 'object') Object.assign(headers, field);
|
||||
else headers[field] = value;
|
||||
return this;
|
||||
},
|
||||
send(body) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue