website refactor

This commit is contained in:
2026-01-16 01:00:03 +01:00
parent ce7be39155
commit a98e3e3166
286 changed files with 5522 additions and 5261 deletions

View File

@@ -1,9 +1,7 @@
import { Result } from '@/lib/contracts/Result';
import { LeagueService } from '@/lib/services/leagues/LeagueService';
import { LeaguesApiClient } from '@/lib/api/leagues/LeaguesApiClient';
import { ConsoleErrorReporter } from '@/lib/infrastructure/logging/ConsoleErrorReporter';
import { ConsoleLogger } from '@/lib/infrastructure/logging/ConsoleLogger';
import type { CreateLeagueInputDTO } from '@/lib/types/generated/CreateLeagueInputDTO';
import { DomainError } from '@/lib/contracts/services/Service';
/**
* CreateLeagueMutation
@@ -15,22 +13,19 @@ export class CreateLeagueMutation {
private service: LeagueService;
constructor() {
// Manual wiring for serverless
const baseUrl = process.env.NEXT_PUBLIC_API_URL || '';
const errorReporter = new ConsoleErrorReporter();
const logger = new ConsoleLogger();
const apiClient = new LeaguesApiClient(baseUrl, errorReporter, logger);
this.service = new LeagueService();
}
async execute(input: CreateLeagueInputDTO): Promise<Result<string, string>> {
async execute(input: CreateLeagueInputDTO): Promise<Result<string, DomainError>> {
try {
const result = await this.service.createLeague(input);
return Result.ok(result.leagueId);
} catch (error) {
if (result.isErr()) {
return Result.err(result.getError());
}
return Result.ok(result.unwrap().leagueId);
} catch (error: any) {
console.error('CreateLeagueMutation failed:', error);
return Result.err('Failed to create league');
return Result.err({ type: 'serverError', message: error.message || 'Failed to create league' });
}
}
}
}