mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00
chore: Redis CA certificate handling with proper logging + JSDocs
This commit is contained in:
parent
f2181c9e27
commit
5f0377b957
1 changed files with 7 additions and 5 deletions
12
api/cache/cacheConfig.js
vendored
12
api/cache/cacheConfig.js
vendored
|
@ -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,23 +35,24 @@ 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) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue