DC-004: Fix all 19 ESLint warnings (zero remaining)
Removed unused imports (path, validateStartupConfig, platformPaths), renamed unused destructures (_timeout, _logEntry), replaced nested ternaries with lookup tables, added eslint-disable comments on require-await functions that are intentionally async for API stability, and extracted helper functions to reduce max-depth and complexity in app.js, dns.js, provider-dns.js, and site.js. All 879 tests pass.
This commit is contained in:
@@ -82,6 +82,20 @@ async function refreshDnsToken(username, password, server, fetchT, log) {
|
||||
/**
|
||||
* Ensure we have a valid DNS token (auto-refresh if needed)
|
||||
*/
|
||||
async function tryCredentialPair(dnsId, role, primaryIp, siteConfig, credentialManager, fetchT, log) {
|
||||
try {
|
||||
const username = await credentialManager.retrieve(`dns.${dnsId}.${role}.username`);
|
||||
const password = await credentialManager.retrieve(`dns.${dnsId}.${role}.password`);
|
||||
if (username && password) {
|
||||
return await refreshDnsToken(username, password, primaryIp, fetchT, log);
|
||||
}
|
||||
return null;
|
||||
} catch (err) {
|
||||
log.error('dns', `Per-server ${role} credential error`, { dnsId, error: err.message });
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function ensureValidDnsToken(siteConfig, credentialManager, fetchT, log) {
|
||||
// Check if token is valid and not expired
|
||||
if (dnsToken && dnsTokenExpiry && new Date() < new Date(dnsTokenExpiry)) {
|
||||
@@ -93,15 +107,8 @@ async function ensureValidDnsToken(siteConfig, credentialManager, fetchT, log) {
|
||||
const dnsId = dnsIpToDnsId(primaryIp, siteConfig);
|
||||
if (dnsId) {
|
||||
for (const role of ['admin', 'readonly']) {
|
||||
try {
|
||||
const username = await credentialManager.retrieve(`dns.${dnsId}.${role}.username`);
|
||||
const password = await credentialManager.retrieve(`dns.${dnsId}.${role}.password`);
|
||||
if (username && password) {
|
||||
return await refreshDnsToken(username, password, primaryIp, fetchT, log);
|
||||
}
|
||||
} catch (err) {
|
||||
log.error('dns', `Per-server ${role} credential error`, { dnsId, error: err.message });
|
||||
}
|
||||
const result = await tryCredentialPair(dnsId, role, primaryIp, siteConfig, credentialManager, fetchT, log);
|
||||
if (result) return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user