chore: resolve lint warnings with targeted type and rule fixes
This commit is contained in:
@@ -19,6 +19,13 @@ interface KomgaUrlBuilder {
|
||||
params?: Record<string, string | string[]>;
|
||||
}
|
||||
|
||||
interface FetchErrorLike {
|
||||
code?: string;
|
||||
cause?: {
|
||||
code?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export abstract class BaseApiService {
|
||||
protected static async getKomgaConfig(): Promise<AuthConfig> {
|
||||
try {
|
||||
@@ -146,9 +153,10 @@ export abstract class BaseApiService {
|
||||
? { revalidate: options.revalidate }
|
||||
: undefined,
|
||||
});
|
||||
} catch (fetchError: any) {
|
||||
} catch (fetchError: unknown) {
|
||||
const normalizedError = fetchError as FetchErrorLike;
|
||||
// Gestion spécifique des erreurs DNS
|
||||
if (fetchError?.cause?.code === "EAI_AGAIN" || fetchError?.code === "EAI_AGAIN") {
|
||||
if (normalizedError.cause?.code === "EAI_AGAIN" || normalizedError.code === "EAI_AGAIN") {
|
||||
logger.error(`DNS resolution failed for ${url}. Retrying with different DNS settings...`);
|
||||
|
||||
response = await fetch(url, {
|
||||
@@ -168,7 +176,7 @@ export abstract class BaseApiService {
|
||||
? { revalidate: options.revalidate }
|
||||
: undefined,
|
||||
});
|
||||
} else if (fetchError?.cause?.code === "UND_ERR_CONNECT_TIMEOUT") {
|
||||
} else if (normalizedError.cause?.code === "UND_ERR_CONNECT_TIMEOUT") {
|
||||
// Retry automatique sur timeout de connexion (cold start)
|
||||
logger.info(`⏱️ Connection timeout for ${url}. Retrying once (cold start)...`);
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import { PreferencesService } from "./preferences.service";
|
||||
import { ERROR_CODES } from "../../constants/errorCodes";
|
||||
import { AppError } from "../../utils/errors";
|
||||
|
||||
type ErrorWithStatusParams = AppError & { params?: { status?: number } };
|
||||
|
||||
export class BookService extends BaseApiService {
|
||||
private static readonly CACHE_TTL = 60; // 1 minute
|
||||
|
||||
@@ -26,7 +28,7 @@ export class BookService extends BaseApiService {
|
||||
|
||||
return {
|
||||
book,
|
||||
pages: pages.map((page: any) => page.number),
|
||||
pages: pages.map((page) => page.number),
|
||||
};
|
||||
} catch (error) {
|
||||
throw new AppError(ERROR_CODES.BOOK.NOT_FOUND, {}, error);
|
||||
@@ -43,7 +45,7 @@ export class BookService extends BaseApiService {
|
||||
if (
|
||||
error instanceof AppError &&
|
||||
error.code === ERROR_CODES.KOMGA.HTTP_ERROR &&
|
||||
(error as any).params?.status === 404
|
||||
(error as ErrorWithStatusParams).params?.status === 404
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ interface KomgaLibraryRaw {
|
||||
unavailable: boolean;
|
||||
}
|
||||
|
||||
type KomgaCondition = Record<string, unknown>;
|
||||
|
||||
export class LibraryService extends BaseApiService {
|
||||
private static readonly CACHE_TTL = 300; // 5 minutes
|
||||
|
||||
@@ -83,7 +85,7 @@ export class LibraryService extends BaseApiService {
|
||||
const headers = { "Content-Type": "application/json" };
|
||||
|
||||
// Construction du body de recherche pour Komga
|
||||
let condition: any;
|
||||
let condition: KomgaCondition;
|
||||
|
||||
if (unreadOnly) {
|
||||
condition = {
|
||||
@@ -101,7 +103,7 @@ export class LibraryService extends BaseApiService {
|
||||
condition = { libraryId: { operator: "is", value: libraryId } };
|
||||
}
|
||||
|
||||
const searchBody: { condition: any; fullTextSearch?: string } = { condition };
|
||||
const searchBody: { condition: KomgaCondition; fullTextSearch?: string } = { condition };
|
||||
|
||||
const params: Record<string, string | string[]> = {
|
||||
page: String(page),
|
||||
|
||||
@@ -55,13 +55,15 @@ export class PreferencesService {
|
||||
const user = await this.getCurrentUser();
|
||||
const userId = parseInt(user.id, 10);
|
||||
|
||||
const updateData: Record<string, any> = {};
|
||||
const updateData: Prisma.PreferencesUpdateInput = {};
|
||||
if (preferences.showThumbnails !== undefined)
|
||||
updateData.showThumbnails = preferences.showThumbnails;
|
||||
if (preferences.showOnlyUnread !== undefined)
|
||||
updateData.showOnlyUnread = preferences.showOnlyUnread;
|
||||
if (preferences.displayMode !== undefined) updateData.displayMode = preferences.displayMode;
|
||||
if (preferences.background !== undefined) updateData.background = preferences.background;
|
||||
if (preferences.background !== undefined) {
|
||||
updateData.background = preferences.background as unknown as Prisma.InputJsonValue;
|
||||
}
|
||||
if (preferences.readerPrefetchCount !== undefined)
|
||||
updateData.readerPrefetchCount = preferences.readerPrefetchCount;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ type PendingRequest<T> = Promise<T>;
|
||||
|
||||
class RequestDeduplicationService {
|
||||
// Map pour tracker les requêtes en cours par clé unique
|
||||
private pendingRequests = new Map<string, PendingRequest<any>>();
|
||||
private pendingRequests = new Map<string, PendingRequest<unknown>>();
|
||||
|
||||
/**
|
||||
* Exécute une requête de manière dédupliquée
|
||||
|
||||
@@ -9,6 +9,8 @@ import { AppError } from "../../utils/errors";
|
||||
import type { UserPreferences } from "@/types/preferences";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
type KomgaCondition = Record<string, unknown>;
|
||||
|
||||
export class SeriesService extends BaseApiService {
|
||||
private static readonly CACHE_TTL = 120; // 2 minutes
|
||||
|
||||
@@ -34,7 +36,7 @@ export class SeriesService extends BaseApiService {
|
||||
const headers = { "Content-Type": "application/json" };
|
||||
|
||||
// Construction du body de recherche pour Komga
|
||||
let condition: any;
|
||||
let condition: KomgaCondition;
|
||||
|
||||
if (unreadOnly) {
|
||||
// Utiliser allOf pour combiner seriesId avec anyOf pour UNREAD ou IN_PROGRESS
|
||||
|
||||
@@ -14,13 +14,13 @@ export function formatDate(date: string | Date): string {
|
||||
});
|
||||
}
|
||||
|
||||
export function debounce<T extends (...args: any[]) => void>(
|
||||
func: T,
|
||||
export function debounce<TArgs extends unknown[]>(
|
||||
func: (...args: TArgs) => void,
|
||||
wait: number
|
||||
): (...args: Parameters<T>) => void {
|
||||
): (...args: TArgs) => void {
|
||||
let timeout: NodeJS.Timeout;
|
||||
|
||||
return function executedFunction(...args: Parameters<T>) {
|
||||
return function executedFunction(...args: TArgs) {
|
||||
const later = () => {
|
||||
clearTimeout(timeout);
|
||||
func(...args);
|
||||
|
||||
Reference in New Issue
Block a user