Files
Sami f865790fe1 fix(routes): restore ctx access in 15 route files broken by Phase 2.1 refactor
The modular refactor changed function signatures to destructured deps but
left internal ctx.* references intact, causing "ctx is not defined" errors
on /api/config, /api/logo, and many other endpoints. Also implements
loadTotpConfig and saveTotpConfig which were left as stubs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-30 03:01:29 -07:00

43 lines
1.2 KiB
JavaScript

const express = require('express');
/**
* Config routes aggregator
* @param {Object} ctx - Application context (for backward compatibility)
* @returns {express.Router}
*/
module.exports = function(ctx) {
const router = express.Router();
// Common deps for all config routes
const baseDeps = {
configStateManager: ctx.configStateManager,
servicesStateManager: ctx.servicesStateManager,
asyncHandler: ctx.asyncHandler,
log: ctx.log
};
// Additional deps for backup route
const backupDeps = {
...baseDeps,
SERVICES_FILE: ctx.SERVICES_FILE,
CONFIG_FILE: ctx.CONFIG_FILE,
TOTP_CONFIG_FILE: ctx.TOTP_CONFIG_FILE,
TAILSCALE_CONFIG_FILE: ctx.TAILSCALE_CONFIG_FILE,
NOTIFICATIONS_FILE: ctx.NOTIFICATIONS_FILE,
caddy: ctx.caddy,
dns: ctx.dns,
fetchT: ctx.fetchT,
totpConfig: ctx.totpConfig,
credentialManager: ctx.credentialManager,
loadSiteConfig: ctx.loadSiteConfig,
loadNotificationConfig: ctx.loadNotificationConfig,
session: ctx.session,
saveTotpConfig: ctx.saveTotpConfig
};
router.use(require('./settings')(ctx));
router.use(require('./assets')(ctx));
router.use(require('./backup')(backupDeps));
return router;
};