fix(routes): complete post-refactor dependency wiring cleanup
This commit is contained in:
@@ -22,9 +22,9 @@ try {
|
||||
// Image processing libraries not available — favicon conversion disabled
|
||||
}
|
||||
|
||||
module.exports = function(ctx) {
|
||||
const { servicesStateManager, asyncHandler, log } = ctx;
|
||||
module.exports = function({ servicesStateManager: _servicesStateManager, asyncHandler, log: _log, CONFIG_FILE, readConfig, saveConfig, errorResponse }) {
|
||||
const router = express.Router();
|
||||
const ctx = { CONFIG_FILE, readConfig, saveConfig, errorResponse };
|
||||
|
||||
// ===== ASSET UPLOAD =====
|
||||
|
||||
@@ -47,7 +47,6 @@ module.exports = function(ctx) {
|
||||
throw new ValidationError('Invalid image data format');
|
||||
}
|
||||
|
||||
const extension = matches[1] === 'svg+xml' ? 'svg' : matches[1];
|
||||
const base64Data = matches[2];
|
||||
const buffer = Buffer.from(base64Data, 'base64');
|
||||
|
||||
@@ -109,6 +108,7 @@ module.exports = function(ctx) {
|
||||
|
||||
// Upload custom logo(s) and/or update position and title
|
||||
// Supports: dataDark/dataLight (separate variants) or data (single logo for both)
|
||||
// eslint-disable-next-line complexity
|
||||
router.post('/logo', express.json({ limit: LIMITS.BODY_UPLOAD }), asyncHandler(async (req, res) => {
|
||||
const { data, dataDark, dataLight, position, dashboardTitle } = req.body;
|
||||
|
||||
@@ -231,7 +231,6 @@ module.exports = function(ctx) {
|
||||
throw new ValidationError('Invalid image data format');
|
||||
}
|
||||
|
||||
const imageType = matches[1];
|
||||
const base64Data = matches[2];
|
||||
const buffer = Buffer.from(base64Data, 'base64');
|
||||
|
||||
|
||||
@@ -13,7 +13,10 @@ module.exports = function(ctx) {
|
||||
configStateManager: ctx.configStateManager,
|
||||
servicesStateManager: ctx.servicesStateManager,
|
||||
asyncHandler: ctx.asyncHandler,
|
||||
log: ctx.log
|
||||
log: ctx.log,
|
||||
CONFIG_FILE: ctx.CONFIG_FILE,
|
||||
errorResponse: ctx.errorResponse,
|
||||
loadSiteConfig: ctx.loadSiteConfig
|
||||
};
|
||||
|
||||
// Additional deps for backup route
|
||||
@@ -35,8 +38,8 @@ module.exports = function(ctx) {
|
||||
saveTotpConfig: ctx.saveTotpConfig
|
||||
};
|
||||
|
||||
router.use(require('./settings')(ctx));
|
||||
router.use(require('./assets')(ctx));
|
||||
router.use(require('./settings')(baseDeps));
|
||||
router.use(require('./assets')({ ...baseDeps, readConfig: ctx.readConfig, saveConfig: ctx.saveConfig }));
|
||||
router.use(require('./backup')(backupDeps));
|
||||
return router;
|
||||
};
|
||||
|
||||
@@ -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