refactor(backend): standardize error responses, logging, pagination

- errorResponse(res, error, status, publicMessage) in routeHelpers,
  wired into 125 catch blocks across 10 route files; wire format
  ({ error: <string> }) unchanged byte-for-byte
- Replace remaining console.* with logger across src (178 sites);
  3 intentional console sites kept (install boot, unbound .catch ref)
- Adopt getPagination in 6 routes where semantics match exactly
This commit is contained in:
Paul Nothaft
2026-07-03 07:49:45 +02:00
parent d44ead41c5
commit 6eb46d8c31
41 changed files with 372 additions and 482 deletions
+3 -2
View File
@@ -1,5 +1,6 @@
const axios = require('axios');
const { db } = require('../database/db');
const logger = require('../utils/logger');
async function verifyRecaptcha(token) {
// Check if reCAPTCHA is enabled
@@ -32,7 +33,7 @@ async function verifyRecaptcha(token) {
// If no secret key configured, fail closed
if (!secretKey) {
console.warn('reCAPTCHA enabled but no secret key configured — blocking request');
logger.warn('reCAPTCHA enabled but no secret key configured — blocking request');
return false;
}
@@ -50,7 +51,7 @@ async function verifyRecaptcha(token) {
return response.data.success === true;
} catch (error) {
console.error('reCAPTCHA verification error:', error);
logger.error('reCAPTCHA verification error:', error);
return false;
}
}