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>
This commit is contained in:
@@ -14,7 +14,8 @@ const { DOCKER } = require('../../constants');
|
||||
* @param {Object} deps.log - Logger instance
|
||||
* @returns {express.Router}
|
||||
*/
|
||||
module.exports = function({ docker, credentialManager, servicesStateManager, asyncHandler, errorResponse, log }) {
|
||||
module.exports = function(ctx) {
|
||||
const { docker, credentialManager, servicesStateManager, asyncHandler, errorResponse, log } = ctx;
|
||||
const router = express.Router();
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,9 +61,9 @@ module.exports = function(ctx) {
|
||||
res.json({ success: true, recipe: { id: req.params.recipeId, ...recipe } });
|
||||
}, 'recipe-template-detail'));
|
||||
|
||||
// Mount deploy and manage sub-routes
|
||||
router.use(deployRoutes(deps));
|
||||
router.use(manageRoutes(deps));
|
||||
// Mount deploy and manage sub-routes — pass full ctx for sub-routes that reference ctx.*
|
||||
router.use(deployRoutes(ctx));
|
||||
router.use(manageRoutes(ctx));
|
||||
|
||||
return router;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,8 @@ const express = require('express');
|
||||
const { DOCKER } = require('../../constants');
|
||||
const { NotFoundError } = require('../../errors');
|
||||
|
||||
module.exports = function({ servicesStateManager, asyncHandler, log }) {
|
||||
module.exports = function(ctx) {
|
||||
const { servicesStateManager, asyncHandler, log } = ctx;
|
||||
const router = express.Router();
|
||||
/**
|
||||
* Recipes management routes factory
|
||||
|
||||
Reference in New Issue
Block a user