// Server-side startup checks - runs when Next.js server starts let startupComplete = false export async function runStartupChecks() { if (startupComplete) return // Only run once console.log('\nšŸš€ NextJS Boilerplate - Running startup checks...') console.log('='.repeat(60)) try { // Test MongoDB connection const { testMongoConnection } = await import('./mongodb') const mongoStatus = await testMongoConnection() // Test Redis connection (optional) let redisStatus = false try { const { connectRedis } = await import('./redis') const redisClient = await connectRedis() await redisClient.ping() console.log('āœ… Redis connection successful') redisStatus = true } catch (error) { console.log('āš ļø Redis connection failed (optional service)') console.log(' → Redis is used for session storage but app will work without it') } console.log('='.repeat(60)) if (mongoStatus) { console.log('šŸŽ‰ All critical services connected - App ready!') console.log(` → Local: http://localhost:${process.env.PORT || 3006}`) console.log(` → Database: Connected to MongoDB`) console.log(` → Sessions: ${redisStatus ? 'Redis enabled' : 'Fallback to memory'}`) } else { console.log('āŒ Critical services failed - App may not work properly') console.log(' → Check MongoDB connection and try again') } console.log('='.repeat(60)) startupComplete = true } catch (error) { console.error('āŒ Startup checks failed:', error) console.log('='.repeat(60)) } } // Export for explicit use in layout