import { Response } from 'express'

// Consistent success response helper.
export const sendSuccess = <T>(
  res: Response,
  data: T,
  message = 'Success',
  statusCode = 200
) => {
  res.status(statusCode).json({
    success: true,
    message,
    data,
  })
}

// Consistent paginated response helper.
export const sendPaginated = <T>(
  res: Response,
  rows: T[],
  total: number,
  page: number,
  pageSize: number,
  message = 'Success'
) => {
  res.status(200).json({
    success: true,
    message,
    data: {
      rows,
      pagination: {
        total,
        page,
        pageSize,
        totalPages: Math.ceil(total / pageSize),
      },
    },
  })
}
