/**
 * Create a standardized error response
 * @param message - The error message
 * @param code - Error code (e.g., 'UNAUTHORIZED', 'NOT_FOUND')
 * @param details - Additional error details (only included in development)
 * @returns Standardized error response object
 */ export function createErrorResponse(message, code = "UNKNOWN_ERROR", details) {
    return {
        error: {
            message,
            code,
            timestamp: new Date().toISOString(),
            ...process.env.NODE_ENV === "development" && details && {
                details
            }
        }
    };
}
/**
 * Send a standardized error response
 * @param res - Express response object
 * @param status - HTTP status code
 * @param message - Error message
 * @param code - Error code
 * @param details - Additional details
 */ export function sendErrorResponse(res, status, message, code = "UNKNOWN_ERROR", details) {
    res.status(status).json(createErrorResponse(message, code, details));
}
// Common error codes
export const ErrorCodes = {
    // Authentication errors
    UNAUTHORIZED: "UNAUTHORIZED",
    INVALID_TOKEN: "INVALID_TOKEN",
    TOKEN_EXPIRED: "TOKEN_EXPIRED",
    // Validation errors
    VALIDATION_ERROR: "VALIDATION_ERROR",
    INVALID_INPUT: "INVALID_INPUT",
    MISSING_FIELD: "MISSING_FIELD",
    // Resource errors
    NOT_FOUND: "NOT_FOUND",
    ALREADY_EXISTS: "ALREADY_EXISTS",
    // Permission errors
    FORBIDDEN: "FORBIDDEN",
    ACCESS_DENIED: "ACCESS_DENIED",
    // Rate limiting
    RATE_LIMIT_EXCEEDED: "RATE_LIMIT_EXCEEDED",
    // Server errors
    INTERNAL_ERROR: "INTERNAL_ERROR",
    DATABASE_ERROR: "DATABASE_ERROR",
    SERVICE_UNAVAILABLE: "SERVICE_UNAVAILABLE"
};

//# sourceMappingURL=errorResponse.js.map