From e432b21d670ef1684edd43db37761bf2da134671 Mon Sep 17 00:00:00 2001 From: Ryderjj89 Date: Sun, 28 Sep 2025 12:35:29 -0400 Subject: [PATCH] Add detailed debugging logs to getBooks function to diagnose NKJV directory reading issue --- backend/src/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/src/index.js b/backend/src/index.js index 743761ac..99007d2e 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -75,7 +75,11 @@ async function readMarkdownFile(filePath) { async function getBooks(version = 'esv') { try { const dataDir = getDataDir(version); + console.log(`Attempting to read books from: ${dataDir} for version: ${version}`); + const items = await fs.readdir(dataDir); + console.log(`Found ${items.length} items in ${dataDir}`); + const bookDirs = []; for (const item of items) { @@ -83,21 +87,26 @@ async function getBooks(version = 'esv') { const stat = await fs.stat(itemPath); if (stat.isDirectory()) { + console.log(`Checking directory: ${item}`); // Check if directory contains markdown files try { const files = await fs.readdir(itemPath); if (files.some(file => file.endsWith('.md'))) { bookDirs.push(item); + console.log(`Added book: ${item} (${files.length} files)`); } } catch (error) { // Skip directories we can't read + console.log(`Could not read files in ${item}: ${error.message}`); continue; } } } + console.log(`Found ${bookDirs.length} books for version ${version}:`, bookDirs.slice(0, 5)); return bookDirs; } catch (error) { + console.error(`Failed to read bible data directory for version ${version}:`, error.message); throw new Error(`Failed to read bible data directory for version ${version}`); } }