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>
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
const express = require('express');
|
|
|
|
/**
|
|
* Arr routes aggregator
|
|
* Assembles all arr sub-routes with their dependencies
|
|
* @param {Object} ctx - Application context (for backward compatibility)
|
|
* @returns {express.Router}
|
|
*/
|
|
module.exports = function(ctx) {
|
|
const router = express.Router();
|
|
|
|
// Extract dependencies from context
|
|
const deps = {
|
|
docker: ctx.docker,
|
|
credentialManager: ctx.credentialManager,
|
|
servicesStateManager: ctx.servicesStateManager,
|
|
fetchT: ctx.fetchT,
|
|
asyncHandler: ctx.asyncHandler,
|
|
errorResponse: ctx.errorResponse,
|
|
log: ctx.log,
|
|
// Additional context properties needed by arr routes
|
|
notification: ctx.notification,
|
|
safeErrorMessage: ctx.safeErrorMessage
|
|
};
|
|
|
|
// Initialize helpers with dependencies
|
|
const helpers = require('./helpers')(ctx);
|
|
|
|
// Mount sub-routes — pass full ctx so sub-routes can reference ctx.* properties
|
|
const subCtx = Object.assign({}, ctx, { helpers });
|
|
router.use(require('./detect')(subCtx));
|
|
router.use(require('./credentials')(subCtx));
|
|
router.use(require('./config')(subCtx));
|
|
router.use(require('./smart-connect')(subCtx));
|
|
router.use(require('./plex')(subCtx));
|
|
|
|
return router;
|
|
};
|