chore: Redis CA certificate handling with proper logging + JSDocs

This commit is contained in:
Danny Avila 2025-09-18 20:23:54 -04:00
parent f2181c9e27
commit 5f0377b957
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956

View file

@ -1,4 +1,5 @@
const fs = require('fs');
const { logger } = require('@librechat/data-schemas');
const { math, isEnabled } = require('@librechat/api');
const { CacheKeys } = require('librechat-data-provider');
@ -34,7 +35,9 @@ if (FORCED_IN_MEMORY_CACHE_NAMESPACES.length > 0) {
}
}
// Helper function to safely read Redis CA certificate
/** Helper function to safely read Redis CA certificate from file
* @returns {string|null} The contents of the CA certificate file, or null if not set or on error
*/
const getRedisCA = () => {
const caPath = process.env.REDIS_CA;
if (!caPath) {
@ -42,15 +45,14 @@ const getRedisCA = () => {
}
try {
// Check if file exists and is readable before attempting to read
if (fs.existsSync(caPath)) {
return fs.readFileSync(caPath, 'utf8');
} else {
console.warn(`Redis CA certificate file not found: ${caPath}`);
logger.warn(`Redis CA certificate file not found: ${caPath}`);
return null;
}
} catch (error) {
console.error(`Failed to read Redis CA certificate file '${caPath}':`, error.message);
logger.error(`Failed to read Redis CA certificate file '${caPath}':`, error.message);
return null;
}
};