refacto: tentative de refacto
This commit is contained in:
@@ -2,16 +2,13 @@
|
||||
|
||||
import { AuthError } from "@/types/auth";
|
||||
|
||||
interface AuthUser {
|
||||
id: string;
|
||||
email: string;
|
||||
roles: string[];
|
||||
authenticated: boolean;
|
||||
}
|
||||
class AuthService {
|
||||
private static instance: AuthService;
|
||||
|
||||
private constructor() {}
|
||||
// Constructeur privé pour le pattern Singleton
|
||||
private constructor() {
|
||||
// Pas d'initialisation nécessaire
|
||||
}
|
||||
|
||||
public static getInstance(): AuthService {
|
||||
if (!AuthService.instance) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { cookies } from "next/headers";
|
||||
import { AuthConfig } from "@/types/auth";
|
||||
import { serverCacheService } from "./server-cache.service";
|
||||
import { ConfigDBService } from "./config-db.service";
|
||||
@@ -71,18 +70,12 @@ export abstract class BaseApiService {
|
||||
});
|
||||
}
|
||||
|
||||
// Log de l'URL finale
|
||||
console.log(`🔄 [Komga API] ${url.toString()}`);
|
||||
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
protected static async fetchFromApi<T>(url: string, headers: Headers): Promise<T> {
|
||||
const response = await fetch(url, { headers });
|
||||
|
||||
// Log du résultat de la requête
|
||||
console.log(`📡 [Komga API] ${response.status} ${response.statusText} - ${url}`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur HTTP: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@ export class ImageService extends BaseApiService {
|
||||
async () => {
|
||||
const response = await fetch(url, { headers });
|
||||
|
||||
// Log du résultat de la requête
|
||||
console.log(`📡 [Komga API] ${response.status} ${response.statusText} - ${url}`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur HTTP: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
type CacheEntry = {
|
||||
data: any;
|
||||
timestamp: number;
|
||||
ttl: number;
|
||||
};
|
||||
|
||||
class ServerCacheService {
|
||||
private static instance: ServerCacheService;
|
||||
private cache: Map<string, { data: unknown; expiry: number }> = new Map();
|
||||
@@ -94,14 +88,11 @@ class ServerCacheService {
|
||||
type: keyof typeof ServerCacheService.DEFAULT_TTL = "DEFAULT"
|
||||
): Promise<T> {
|
||||
const now = Date.now();
|
||||
console.log("👀 Getting or setting cache for key:", key);
|
||||
const cached = this.cache.get(key);
|
||||
|
||||
if (cached && cached.expiry > now) {
|
||||
console.log("✅ Cache hit for key:", key);
|
||||
return cached.data as T;
|
||||
}
|
||||
console.log("❌ Cache not hit for key:", key);
|
||||
|
||||
try {
|
||||
const data = await fetcher();
|
||||
|
||||
Reference in New Issue
Block a user