Skip to content

Commit a61934d

Browse files
fix(home): address remaining review — JSDoc, CASL manage, log errors, cache isSet
- Add @returns {void} to readiness controller JSDoc - Use can('manage', 'Readiness') matching standard CASL pattern - Log readiness check failures at boot instead of swallowing - Cache isSet(config.domain) to avoid duplicate calls
1 parent 18dc40d commit a61934d

4 files changed

Lines changed: 8 additions & 6 deletions

File tree

lib/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ const logConfiguration = async () => {
112112
const icon = c.status === 'ok' ? chalk.green('OK') : chalk.yellow('WARN');
113113
console.log(` ${icon} ${c.category.padEnd(12)} ${c.message}`);
114114
});
115-
} catch (_err) {
116-
// Non-blocking — readiness check failure should not prevent boot
115+
} catch (err) {
116+
console.log(chalk.yellow(` SaaS readiness check failed: ${err.message}`));
117117
}
118118
}
119119
};

modules/home/controllers/home.controller.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ const health = (req, res) => {
9797
};
9898

9999
/**
100-
* @desc Endpoint to return SaaS readiness checks (admin only)
100+
* @desc Endpoint to return SaaS readiness checks (admin only).
101101
* @param {Object} req - Express request object
102102
* @param {Object} res - Express response object
103+
* @returns {void}
103104
*/
104105
const readiness = (req, res) => {
105106
try {

modules/home/policies/home.policy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
export function homeAbilities(user, membership, { can }) {
1414
can('read', 'Home');
1515
if (Array.isArray(user?.roles) && user.roles.includes('admin')) {
16-
can('read', 'Readiness');
16+
can('manage', 'Readiness');
1717
}
1818
}
1919

modules/home/services/home.service.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,11 @@ const getReadinessStatus = () => {
119119
const checks = [];
120120

121121
// config — domain
122+
const domainSet = isSet(config.domain);
122123
checks.push({
123124
category: 'config',
124-
status: isSet(config.domain) ? 'ok' : 'warning',
125-
message: isSet(config.domain) ? 'Domain configured' : 'Domain not configured',
125+
status: domainSet ? 'ok' : 'warning',
126+
message: domainSet ? 'Domain configured' : 'Domain not configured',
126127
});
127128

128129
// security — JWT secret

0 commit comments

Comments
 (0)