DC-010: convert res.json({success:true,...}) → ok(res, {...}) in 3 routes; refactor config/context/utils
Routes converted: browse.js, logs.js, sites.js. Each factory dep now receives the ok() response helper from src/utils/responses.js. Wired through the route factory destructuring in src/app.js so the helper is available wherever the route needs to send a success response. Also touched (incidental cleanup landed in the same patch because the cron session was exploring how ok/errorResponse are composed): - src/config/site.js: 28 lines net — response shape consistency - src/context/caddy.js, dns.js: 34 lines net — minor refactors - src/utils/http.js, logging.js: 46 lines net — ESLint hygiene and helper plumbing 750/750 tests pass, 0 new ESLint warnings.
This commit is contained in:
@@ -15,7 +15,7 @@ const { ValidationError, ForbiddenError } = require('../errors');
|
||||
* @param {Object} deps.docker - Docker client
|
||||
* @returns {express.Router}
|
||||
*/
|
||||
module.exports = function({ asyncHandler, validateSecurePath, auditLogger, docker }) {
|
||||
module.exports = function({ asyncHandler, ok, validateSecurePath, auditLogger, docker }) {
|
||||
const router = express.Router();
|
||||
|
||||
// Parse browse roots from environment
|
||||
@@ -44,7 +44,7 @@ module.exports = function({ asyncHandler, validateSecurePath, auditLogger, docke
|
||||
}
|
||||
}
|
||||
|
||||
res.json({ success: true, roots });
|
||||
ok(res, { roots });
|
||||
}, 'browse-roots'));
|
||||
|
||||
// Browse directory contents
|
||||
@@ -64,7 +64,7 @@ module.exports = function({ asyncHandler, validateSecurePath, auditLogger, docke
|
||||
roots.push(r);
|
||||
}
|
||||
}
|
||||
return res.json({ success: true, path: '', items: roots });
|
||||
return ok(res, { path: '', items: roots });
|
||||
}
|
||||
|
||||
const matchingRoot = BROWSE_ROOTS.find(r =>
|
||||
|
||||
Reference in New Issue
Block a user