import db from '../config/db.js';

// GET /api/health
export const health = async (req, res) => {
  try {
    await db.query('SELECT 1');
    res.json({
      status:    'ok',
      database:  'connected',
      timestamp: new Date().toISOString(),
    });
  } catch (err) {
    res.status(500).json({
      status:   'error',
      database: 'disconnected',
      message:  err.message,
    });
  }
};