refactor api modules

This commit is contained in:
2025-12-22 19:17:33 +01:00
parent c90b2166c1
commit 1333f5e907
100 changed files with 2226 additions and 1936 deletions

View File

@@ -7,19 +7,19 @@ export interface CommandResultDTO {
message?: string;
}
export type CommandApplicationError<E extends string = string> = ApplicationErrorCode<
E,
export type CommandApplicationError = ApplicationErrorCode<
string,
{ message: string }
>;
export class CommandResultPresenter<E extends string = string> {
export class CommandResultPresenter {
private model: CommandResultDTO | null = null;
reset(): void {
this.model = null;
}
present(result: Result<unknown, CommandApplicationError<E>>): void {
present(result: Result<unknown, CommandApplicationError>): void {
if (result.isErr()) {
const error = result.unwrapErr();
this.model = {
@@ -36,7 +36,7 @@ export class CommandResultPresenter<E extends string = string> {
presentSuccess(message?: string): void {
this.model = {
success: true,
message,
...(message !== undefined && { message }),
};
}
@@ -44,7 +44,7 @@ export class CommandResultPresenter<E extends string = string> {
this.model = {
success: false,
errorCode,
message,
...(message !== undefined && { message }),
};
}
@@ -59,4 +59,8 @@ export class CommandResultPresenter<E extends string = string> {
return this.model;
}
get viewModel(): CommandResultDTO {
return this.responseModel;
}
}