import { Response } from 'express';

interface ApiResponse<T> {
    success: boolean;
    data?: T;
    error?: string;
}

export const sendSuccess = <T>(res: Response, data: T, statusCode: number = 200) => {
    const response: ApiResponse<T> = {
        success: true,
        data,
    };
    return res.status(statusCode).json(response);
};

export const sendError = (res: Response, error: string, statusCode: number = 400) => {
    const response: ApiResponse<null> = {
        success: false,
        error,
    };
    return res.status(statusCode).json(response);
};
