fix: correct apps route mount paths - mount all sub-routers at /apps prefix to match frontend API calls
This commit is contained in:
@@ -25,7 +25,6 @@ module.exports = function(ctx) {
|
||||
asyncHandler: ctx.asyncHandler,
|
||||
errorResponse: ctx.errorResponse,
|
||||
log: ctx.log,
|
||||
// Additional context properties needed by routes
|
||||
APP_TEMPLATES: ctx.APP_TEMPLATES,
|
||||
TEMPLATE_CATEGORIES: ctx.TEMPLATE_CATEGORIES,
|
||||
DIFFICULTY_LEVELS: ctx.DIFFICULTY_LEVELS,
|
||||
@@ -40,25 +39,26 @@ module.exports = function(ctx) {
|
||||
ctx: ctx
|
||||
};
|
||||
|
||||
// Initialize helpers with dependencies (ctx is the Koa context)
|
||||
const helpers = initHelpers({ ...deps, ctx });
|
||||
|
||||
// Mount sub-routes — pass full ctx so sub-routes can reference ctx.* properties
|
||||
const subCtx = Object.assign({}, ctx, { helpers });
|
||||
|
||||
try { router.use('/', initDeploy(subCtx)); }
|
||||
// Mount sub-routers at their prefix paths.
|
||||
// Sub-modules define routes at '/' (root of their sub-router).
|
||||
// Final paths: /api/v1/apps/deploy, /api/v1/apps/remove, /api/v1/apps/templates, etc.
|
||||
|
||||
try { router.use('/apps', initDeploy(subCtx)); }
|
||||
catch(e) { (ctx.log || console).error('[apps] deploy routes init failed:', e.message, e.stack); }
|
||||
|
||||
try { router.use('/', initRemoval(subCtx)); }
|
||||
try { router.use('/apps', initRemoval(subCtx)); }
|
||||
catch(e) { (ctx.log || console).error('[apps] removal routes init failed:', e.message, e.stack); }
|
||||
|
||||
try { router.use('/', initTemplates(subCtx)); }
|
||||
try { router.use('/apps', initTemplates(subCtx)); }
|
||||
catch(e) { (ctx.log || console).error('[apps] templates routes init failed:', e.message, e.stack); }
|
||||
|
||||
try { router.use('/', initRestore(Object.assign({}, subCtx, { backupManager: ctx.backupManager }))); }
|
||||
try { router.use('/apps', initRestore(Object.assign({}, subCtx, { backupManager: ctx.backupManager }))); }
|
||||
catch(e) { (ctx.log || console).error('[apps] restore routes init failed:', e.message, e.stack); }
|
||||
|
||||
try { router.use('/', initCompose(subCtx)); }
|
||||
try { router.use('/apps', initCompose(subCtx)); }
|
||||
catch(e) { (ctx.log || console).error('[apps] compose routes init failed:', e.message, e.stack); }
|
||||
|
||||
return router;
|
||||
|
||||
Reference in New Issue
Block a user