const { Pool } = require('pg'); require('dotenv').config(); async function test() { const connectionString = process.env.DATABASE_URL; console.log('Testing connection to:', connectionString ? 'URL present' : 'URL MISSING'); const pool = new Pool({ connectionString, connectionTimeoutMillis: 5000, }); try { const client = await pool.connect(); console.log('Successfully connected to DB!'); const res = await client.query('SELECT NOW()'); console.log('Query result:', res.rows[0]); client.release(); } catch (err) { console.error('Connection failed:', err.message); } finally { await pool.end(); } } test();