const { sequelize } = require('../models');
const logger = require('./logger');

const check = async () => {
  const checks = {
    database: false,
    timestamp: new Date().toISOString(),
    uptime: process.uptime(),
    memory: process.memoryUsage()
  };

  try {
    await sequelize.authenticate();
    checks.database = true;
  } catch (error) {
    logger.error('Database health check failed:', error);
  }

  return {
    status: checks.database ? 'healthy' : 'unhealthy',
    ...checks
  };
};

module.exports = { check };