fix(routes): complete post-refactor dependency wiring cleanup
This commit is contained in:
@@ -5,13 +5,19 @@ const { ValidationError } = require('../../errors');
|
||||
|
||||
/**
|
||||
* Config settings routes factory
|
||||
* @param {Object} ctx - Application context
|
||||
* @param {Object} deps - Explicit dependencies
|
||||
* @param {Object} deps.configStateManager - Config state manager
|
||||
* @param {Function} deps.asyncHandler - Async route handler wrapper
|
||||
* @param {Object} deps.log - Logger instance
|
||||
* @param {string} deps.CONFIG_FILE - Config file path
|
||||
* @param {Function} deps.errorResponse - Error response helper
|
||||
* @param {Function} deps.loadSiteConfig - Site config reload helper
|
||||
* @returns {express.Router}
|
||||
*/
|
||||
module.exports = function(ctx) {
|
||||
const { configStateManager, asyncHandler, log } = ctx;
|
||||
module.exports = function({ configStateManager: _configStateManager, asyncHandler, log, CONFIG_FILE, errorResponse, loadSiteConfig }) {
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const ctx = { CONFIG_FILE, errorResponse, loadSiteConfig };
|
||||
|
||||
// ===== DASHCADDY CONFIG ENDPOINTS =====
|
||||
// Server-side config storage for setup wizard (shared across all browsers/machines)
|
||||
@@ -60,7 +66,9 @@ module.exports = function(ctx) {
|
||||
config.updatedAt = new Date().toISOString();
|
||||
|
||||
await fsp.writeFile(ctx.CONFIG_FILE, JSON.stringify(config, null, 2), 'utf8');
|
||||
ctx.loadSiteConfig(); // Refresh in-memory config
|
||||
if (typeof ctx.loadSiteConfig === 'function') {
|
||||
ctx.loadSiteConfig(); // Refresh in-memory config
|
||||
}
|
||||
log.info('config', 'Config saved', { path: ctx.CONFIG_FILE });
|
||||
|
||||
res.json({ success: true, message: 'Configuration saved', config, warnings });
|
||||
|
||||
Reference in New Issue
Block a user