From 0d21cbb93b5d5481789fe8d79a025b36fbc0148f Mon Sep 17 00:00:00 2001 From: Hermes Date: Wed, 12 Aug 2026 13:06:07 -0700 Subject: [PATCH] Fix: Catalog handles APP_TEMPLATES as object map (not just array) APP_TEMPLATES is exported as { plex: {...}, jellyfin: {...}, ... } not an array. All three catalog endpoints now handle both formats. --- dashcaddy-api/routes/catalog.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dashcaddy-api/routes/catalog.js b/dashcaddy-api/routes/catalog.js index 1488ea1..ee537ec 100644 --- a/dashcaddy-api/routes/catalog.js +++ b/dashcaddy-api/routes/catalog.js @@ -42,9 +42,11 @@ module.exports = function({ APP_TEMPLATES, asyncHandler } = {}) { router.get('/catalog', wrap(async (req, res) => { const { category, sort } = req.query; let apps = APP_TEMPLATES || []; + // APP_TEMPLATES can be an array or an object map { plex: {...}, ... } + let appArray = Array.isArray(apps) ? apps : Object.values(apps); // Build catalog entries - let entries = apps.map(t => ({ + let entries = appArray.map(t => ({ id: t.id || t.name?.toLowerCase().replace(/\s+/g, '-'), name: t.name, description: t.description || '', @@ -87,7 +89,9 @@ module.exports = function({ APP_TEMPLATES, asyncHandler } = {}) { return errorResponse(res, 400, 'Search query (q) is required'); } - const apps = (APP_TEMPLATES || []).filter(t => { + const allApps = APP_TEMPLATES || []; + const appArray = Array.isArray(allApps) ? allApps : Object.values(allApps); + const apps = appArray.filter(t => { const name = (t.name || '').toLowerCase(); const desc = (t.description || '').toLowerCase(); const cat = getTemplateCategory(t).toLowerCase(); @@ -105,7 +109,9 @@ module.exports = function({ APP_TEMPLATES, asyncHandler } = {}) { // GET /api/v1/catalog/:appId — get specific app details router.get('/catalog/:appId', wrap(async (req, res) => { const appId = req.params.appId; - const app = (APP_TEMPLATES || []).find(t => { + const allApps = APP_TEMPLATES || []; + const appArray = Array.isArray(allApps) ? allApps : Object.values(allApps); + const app = appArray.find(t => { const tid = (t.id || t.name?.toLowerCase().replace(/\s+/g, '-')); return tid === appId; });