const { Client } = require('pg'); const client = new Client({ user: 'sergei', host: 'eluxnetworks.net', database: 'wellnuo_app', password: 'W31153Rg31', port: 5432, ssl: { rejectUnauthorized: false } }); const email = process.argv[2]; if (!email) { console.error('Usage: node fetch-otp.js '); process.exit(1); } async function run() { try { await client.connect(); // Get the latest OTP for the email const res = await client.query(` SELECT code FROM public.otp_codes WHERE email = $1 ORDER BY created_at DESC LIMIT 1 `, [email]); if (res.rows.length > 0) { console.log(res.rows[0].code); } else { console.error('No OTP found'); process.exit(1); } } catch (err) { console.error('Database error:', err); process.exit(1); } finally { await client.end(); } } run();