From 1c02131fe0fc7f86d0e09f302ff0141725e46fbb Mon Sep 17 00:00:00 2001 From: Hermes Date: Mon, 3 Aug 2026 00:43:34 -0700 Subject: [PATCH] =?UTF-8?q?fix(server):=20DC-058=20close=203=20P0=20bugs?= =?UTF-8?q?=20=E2=80=94=20restore.js=20missing=20dep,=20dns.js=20ok=20ref,?= =?UTF-8?q?=20dead=20/billing/checkout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. routes/apps/restore.js: backupManager was being passed by the aggregator (routes/apps/index.js:58) but never destructured in the factory signature. Every apps/restore request 500'd with ReferenceError. Added backupManager to the destructure + an explicit throw if missing so the next regression surfaces at startup instead of at the first call. 2. routes/dns.js:555: file imports { success, error } from ../src/utils/responses but used ok(res, ...) (defunct alias). DNS credential save path 500'd. Changed to success() to match the rest of the file. 3. src/utilities/middleware.js: deleted /api/v1/billing/checkout from PUBLIC_ROUTES — dead entry, no route mounted. Drift test caught it (DC-017 guard). Updated the comment to cover both checkout + webhook as removed. Tests: 1428/1428 pass (drift test now green). Lint: 0 no-undef errors across src/ + routes/ (was 7). Refs: DashCaddy audit 2026-08-02 --- dashcaddy-api/routes/apps/restore.js | 3 ++- dashcaddy-api/routes/dns.js | 2 +- dashcaddy-api/src/utilities/middleware.js | 9 ++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dashcaddy-api/routes/apps/restore.js b/dashcaddy-api/routes/apps/restore.js index 8cfe579..81e1434 100644 --- a/dashcaddy-api/routes/apps/restore.js +++ b/dashcaddy-api/routes/apps/restore.js @@ -21,7 +21,8 @@ const DEFAULT_BACKUP_DIR = process.env.BACKUP_DIR || path.join(__dirname, '..', * @param {Function} deps.buildServiceUrl - Service URL builder * @returns {express.Router} */ -module.exports = function({ docker, caddy, servicesStateManager, asyncHandler, errorResponse, log, helpers, APP_TEMPLATES, dns, buildServiceUrl }) { +module.exports = function({ docker, caddy, servicesStateManager, asyncHandler, errorResponse, log, helpers, APP_TEMPLATES, dns, buildServiceUrl, backupManager }) { + if (!backupManager) throw new Error('routes/apps/restore: backupManager dependency is required'); const router = express.Router(); const ctx = { diff --git a/dashcaddy-api/routes/dns.js b/dashcaddy-api/routes/dns.js index 2768601..ed1528c 100644 --- a/dashcaddy-api/routes/dns.js +++ b/dashcaddy-api/routes/dns.js @@ -552,7 +552,7 @@ module.exports = function({ } } - return ok(res, { + return success(res, { message: anySuccess ? 'Credentials saved for one or more servers' : 'All server credential tests failed', results }); diff --git a/dashcaddy-api/src/utilities/middleware.js b/dashcaddy-api/src/utilities/middleware.js index b3f2ace..e1a3316 100644 --- a/dashcaddy-api/src/utilities/middleware.js +++ b/dashcaddy-api/src/utilities/middleware.js @@ -402,11 +402,10 @@ module.exports = function configureMiddleware(app, { { path: '/api/v1/share/:token/preview', exact: true, method: 'GET' }, { path: '/api/v1/share/:token/subscribe', exact: true, method: 'POST' }, { path: '/api/v1/share/:token/redeem-tailscale', exact: true, method: 'POST' }, - { path: '/api/v1/billing/checkout', exact: true, method: 'POST' }, - // /api/v1/billing/webhook was REMOVED: webhooks are handled out-of-process - // by scripts/stripe-license-bridge.js (the merchant webhook secret never - // enters the API process). The PUBLIC_ROUTES allowlist drift test would - // catch any re-add of this dead entry. + // /api/v1/billing/* was REMOVED: billing is handled out-of-process + // (the merchant webhook secret never enters the API process). The + // PUBLIC_ROUTES allowlist drift test guards against re-adding these + // dead entries. // /api/v1/services + status: read-only service metadata that the public // dashboard needs before login (services list widget, status pill). // Writes go through the normal auth gate. CSRF applies to writes as usual.