website refactor
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
*/
|
||||
|
||||
import { EventEmitter } from 'events';
|
||||
import { ApiError } from './ApiError';
|
||||
import { CircuitBreakerRegistry } from './RetryHandler';
|
||||
|
||||
export type ConnectionStatus = 'connected' | 'disconnected' | 'degraded' | 'checking';
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ export class BaseApiClient {
|
||||
/**
|
||||
* Get developer-friendly hint for troubleshooting
|
||||
*/
|
||||
private getDeveloperHint(error: Error, path: string, method: string): string {
|
||||
private getDeveloperHint(error: Error, _path: string, _method: string): string {
|
||||
if (error.message.includes('fetch failed') || error.message.includes('Failed to fetch')) {
|
||||
return 'Check if API server is running and CORS is configured correctly';
|
||||
}
|
||||
@@ -183,7 +183,7 @@ export class BaseApiClient {
|
||||
/**
|
||||
* Get troubleshooting context for network errors
|
||||
*/
|
||||
private getTroubleshootingContext(error: Error, path: string): string {
|
||||
private getTroubleshootingContext(error: Error, _path: string): string {
|
||||
if (typeof window !== 'undefined') {
|
||||
const baseUrl = this.baseUrl;
|
||||
const currentOrigin = window.location.origin;
|
||||
|
||||
@@ -37,7 +37,7 @@ export interface CacheEntry<T> {
|
||||
* Simple in-memory cache for API responses
|
||||
*/
|
||||
class ResponseCache {
|
||||
private cache = new Map<string, CacheEntry<any>>();
|
||||
private cache = new Map<string, CacheEntry<unknown>>();
|
||||
|
||||
/**
|
||||
* Get cached data if not expired
|
||||
@@ -46,20 +46,20 @@ class ResponseCache {
|
||||
const entry = this.cache.get(key);
|
||||
if (!entry) return null;
|
||||
|
||||
if (new Date() > entry.expiry) {
|
||||
if (new globalThis.Date() > entry.expiry) {
|
||||
this.cache.delete(key);
|
||||
return null;
|
||||
}
|
||||
|
||||
return entry.data;
|
||||
return entry.data as T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cached data with expiry
|
||||
*/
|
||||
set<T>(key: string, data: T, ttlMs: number = 300000): void {
|
||||
const now = new Date();
|
||||
const expiry = new Date(now.getTime() + ttlMs);
|
||||
const now = new globalThis.Date();
|
||||
const expiry = new globalThis.Date(now.getTime() + ttlMs);
|
||||
|
||||
this.cache.set(key, {
|
||||
data,
|
||||
@@ -133,7 +133,7 @@ export async function withGracefulDegradation<T>(
|
||||
'API unavailable and no fallback provided',
|
||||
'NETWORK_ERROR',
|
||||
{
|
||||
timestamp: new Date().toISOString(),
|
||||
timestamp: new globalThis.Date().toISOString(),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Retry logic and circuit breaker for API requests
|
||||
*/
|
||||
|
||||
import { ApiError, ApiErrorType } from './ApiError';
|
||||
import { ApiError } from './ApiError';
|
||||
|
||||
export interface RetryConfig {
|
||||
maxRetries: number;
|
||||
|
||||
Reference in New Issue
Block a user