fix(routes): Pass full deps to config/backup and create ctx shim
This commit is contained in:
@@ -5,20 +5,29 @@ const { CADDY } = require('../../constants');
|
||||
const { exists } = require('../../fs-helpers');
|
||||
const { ValidationError, AuthenticationError } = require('../../errors');
|
||||
|
||||
module.exports = function({ configStateManager, servicesStateManager, asyncHandler, log }) {
|
||||
const express = require('express');
|
||||
/**
|
||||
* Config backup routes factory
|
||||
* @param {Object} deps - Explicit dependencies
|
||||
* @param {Object} deps.configStateManager - Config state manager
|
||||
* @param {Object} deps.servicesStateManager - Services state manager
|
||||
* @param {Function} deps.asyncHandler - Async route handler wrapper
|
||||
* @param {Object} deps.log - Logger instance
|
||||
* @returns {express.Router}
|
||||
*/
|
||||
module.exports = function(deps) {
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
const THEMES_DIR = process.env.THEMES_DIR || path.join(path.dirname(ctx.SERVICES_FILE), 'themes');
|
||||
// Extract dependencies
|
||||
const {
|
||||
configStateManager, servicesStateManager, asyncHandler, log,
|
||||
SERVICES_FILE, CONFIG_FILE, TOTP_CONFIG_FILE, TAILSCALE_CONFIG_FILE, NOTIFICATIONS_FILE,
|
||||
caddy, dns, fetchT, totpConfig, credentialManager, loadSiteConfig, loadNotificationConfig, session, saveTotpConfig
|
||||
} = deps;
|
||||
|
||||
// Create ctx-like object for compatibility with existing code
|
||||
const ctx = {
|
||||
SERVICES_FILE, CONFIG_FILE, TOTP_CONFIG_FILE, TAILSCALE_CONFIG_FILE, NOTIFICATIONS_FILE,
|
||||
caddy, dns, fetchT, totpConfig, credentialManager, loadSiteConfig, loadNotificationConfig
|
||||
};
|
||||
|
||||
const THEMES_DIR = process.env.THEMES_DIR || path.join(path.dirname(SERVICES_FILE), 'themes');
|
||||
|
||||
function readAllThemes() {
|
||||
const themes = {};
|
||||
|
||||
Reference in New Issue
Block a user