refactor: achieve 100% biome compliance with comprehensive code quality improvements

- Fix all cognitive complexity violations (63→0 errors)
- Replace 'any' types with proper TypeScript interfaces and generics
- Extract helper functions and custom hooks to reduce complexity
- Fix React hook dependency arrays and useCallback patterns
- Remove unused imports, variables, and functions
- Implement proper formatting across all files
- Add type safety with interfaces like AIProcessingRequestWithSession
- Fix circuit breaker implementation with proper reset() method
- Resolve all accessibility and form labeling issues
- Clean up mysterious './0' file containing biome output

Total: 63 errors → 0 errors, 42 warnings → 0 warnings
This commit is contained in:
2025-07-11 23:49:45 +02:00
committed by Kaj Kowalski
parent 1eea2cc3e4
commit 314326400e
42 changed files with 3171 additions and 2781 deletions

View File

@ -101,11 +101,11 @@ export async function getCSRFTokenFromCookies(): Promise<string | null> {
/**
* Server-side utilities for API routes
*/
export class CSRFProtection {
export const CSRFProtection = {
/**
* Generate and set CSRF token in response
*/
static generateTokenResponse(): {
generateTokenResponse(): {
token: string;
cookie: {
name: string;
@ -132,12 +132,12 @@ export class CSRFProtection {
},
},
};
}
},
/**
* Validate CSRF token from request
*/
static async validateRequest(request: NextRequest): Promise<{
async validateRequest(request: NextRequest): Promise<{
valid: boolean;
error?: string;
}> {
@ -148,7 +148,7 @@ export class CSRFProtection {
}
// Get token from request
const requestToken = await CSRFProtection.getTokenFromRequest(request);
const requestToken = await this.getTokenFromRequest(request);
if (!requestToken) {
return {
valid: false,
@ -188,14 +188,12 @@ export class CSRFProtection {
error: `CSRF validation error: ${error instanceof Error ? error.message : "Unknown error"}`,
};
}
}
},
/**
* Extract token from request (handles different content types)
*/
private static async getTokenFromRequest(
request: NextRequest
): Promise<string | null> {
async getTokenFromRequest(request: NextRequest): Promise<string | null> {
// Check header first
const headerToken = request.headers.get(CSRF_CONFIG.headerName);
if (headerToken) {
@ -223,8 +221,8 @@ export class CSRFProtection {
}
return null;
}
}
},
};
/**
* Client-side utilities