/**
 * Standardized response handlers for API routes
 */

const success = (res, data = {}, statusCode = 200) => {
  res.status(statusCode).json({
    success: true,
    ...data,
  });
};

const error = (res, message, statusCode = 500, additionalData = {}) => {
  res.status(statusCode).json({
    success: false,
    message,
    ...additionalData,
  });
};

const notFound = (res, resource = "Resource") => {
  error(res, `${resource} not found`, 404);
};

const badRequest = (res, message) => {
  error(res, message, 400);
};

module.exports = {
  success,
  error,
  notFound,
  badRequest,
};
