#!/bin/bash
echo "=== PM2 ERROR LOG ==="
pm2 logs sneakerpicks --err --lines 30 --nostream 2>&1

echo "=== TEST DB CONNECTION FROM NODE ==="
cd /var/www/sneakerpicks
node -e "
const pg = require('pg');
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
pool.query('SELECT COUNT(*) FROM products').then(r => console.log('Products:', r.rows[0].count)).catch(e => console.error('DB Error:', e.message)).finally(() => pool.end());
"
