REFACTOR data service

This commit is contained in:
Urtzi Alfaro
2025-08-12 18:17:30 +02:00
parent 7c237c0acc
commit fbe7470ad9
149 changed files with 8528 additions and 7393 deletions

View File

@@ -333,7 +333,12 @@ private buildURL(endpoint: string): string {
size: JSON.stringify(result).length,
});
return result;
// Handle both wrapped and unwrapped responses
// If result has a 'data' property, return it; otherwise return the result itself
if (result && typeof result === 'object' && 'data' in result) {
return result.data as T;
}
return result as T;
} catch (error) {
// Record error metrics
this.recordMetrics({

View File

@@ -7,12 +7,15 @@ export interface RequestConfig {
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
headers?: Record<string, string>;
params?: Record<string, any>;
body?: any;
url?: string;
timeout?: number;
retries?: number;
cache?: boolean;
cacheTTL?: number;
optimistic?: boolean;
background?: boolean;
metadata?: any;
}
export interface ApiResponse<T = any> {
@@ -20,12 +23,14 @@ export interface ApiResponse<T = any> {
message?: string;
status: string;
timestamp?: string;
metadata?: any;
meta?: {
page?: number;
limit?: number;
total?: number;
hasNext?: boolean;
hasPrev?: boolean;
requestId?: string;
};
}