refactor use cases

This commit is contained in:
2026-01-08 15:34:51 +01:00
parent d984ab24a8
commit 52e9a2f6a7
362 changed files with 5192 additions and 8409 deletions

View File

@@ -15,8 +15,6 @@ import type {
import type { Logger } from '@core/shared/application';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
export interface CreateTeamInput {
name: string;
tag: string;
@@ -35,17 +33,14 @@ export type CreateTeamErrorCode =
| 'REPOSITORY_ERROR';
export class CreateTeamUseCase {
constructor(
private readonly teamRepository: ITeamRepository,
constructor(private readonly teamRepository: ITeamRepository,
private readonly membershipRepository: ITeamMembershipRepository,
private readonly logger: Logger,
private readonly output: UseCaseOutputPort<CreateTeamResult>,
) {}
private readonly logger: Logger) {}
async execute(
input: CreateTeamInput,
): Promise<
Result<void, ApplicationErrorCode<CreateTeamErrorCode, { message: string }>>
Result<CreateTeamResult, ApplicationErrorCode<CreateTeamErrorCode, { message: string }>>
> {
this.logger.debug('Executing CreateTeamUseCase', { input });
const { name, tag, description, ownerId, leagues } = input;
@@ -95,8 +90,7 @@ export class CreateTeamUseCase {
const result: CreateTeamResult = { team: createdTeam };
this.logger.debug('CreateTeamUseCase completed successfully.', { result });
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error) {
return Result.err({
code: 'REPOSITORY_ERROR',