The following changes were made by the replace_file_content tool to: /root/aadharbot/index.js. If relevant, proactively run terminal commands to execute this code for the USER. Don't ask for permission. [diff_block_start] @@ -47,6 +47,9 @@ const gateways = require('./gateways'); const { startInternalServer } = require('./aadhaar_service'); +const { fetchWithAgent } = require('./modules/core/httpAgent'); +const { dateDifferenceSeconds, formatDateIST } = require('./modules/core/utils'); + startInternalServer(process.env.API_PORT || 3000); const API_BASE_URL = process.env.API_BASE_URL || 'http://127.0.0.1:3000/api/v2/aadhaar'; @@ -60,42 +60,10 @@ ...options.headers }; const signal = options.signal || AbortSignal.timeout(30000); - const response = await fetch(url, { ...options, headers, signal }); + const response = await fetchWithAgent(url, { ...options, headers, signal }); return response; } -function dateDifferenceSeconds(d1Str, d2Str) { - try { - const t1 = new Date(d1Str.replace(/-/g, '/')).getTime(); - const t2 = new Date(d2Str.replace(/-/g, '/')).getTime(); - if (isNaN(t1) || isNaN(t2)) return 999999; - return Math.abs(t1 - t2) / 1000; - } catch (e) { - console.error("Error:", e); - return 999999; - } -} - -function formatDateIST(date) { - const formatter = new Intl.DateTimeFormat('en-US', { - timeZone: 'Asia/Kolkata', - year: 'numeric', - month: '2-digit', - day: '2-digit', - hour: '2-digit', - minute: '2-digit', - second: '2-digit', - hour12: false - }); - const parts = formatter.formatToParts(date); - const partMap = {}; - for (const part of parts) { - partMap[part.type] = part.value; - } - let hour = partMap.hour; - if (hour === '24') hour = '00'; - return `${partMap.year}-${partMap.month}-${partMap.day} ${hour}:${partMap.minute}:${partMap.second}`; -} // PostgreSQL Configuration let pool = null; [diff_block_end] Please note that the above snippet only shows the MODIFIED lines from the last change. It shows up to 3 lines of unchanged lines before and after the modified lines. The actual file contents may have many more lines not shown.