website refactor

This commit is contained in:
2026-01-16 12:55:48 +01:00
parent 0208334c59
commit 20a42c52fd
83 changed files with 1610 additions and 1238 deletions

View File

@@ -0,0 +1,63 @@
/**
* Application Use Case: GetAllNotificationsUseCase
*
* Retrieves all notifications for a recipient.
*/
import type { Logger } from '@core/shared/application';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { Notification } from '../../domain/entities/Notification';
import type { INotificationRepository } from '../../domain/repositories/INotificationRepository';
export type GetAllNotificationsInput = {
recipientId: string;
};
export interface GetAllNotificationsResult {
notifications: Notification[];
totalCount: number;
}
export type GetAllNotificationsErrorCode = 'REPOSITORY_ERROR';
export class GetAllNotificationsUseCase {
constructor(
private readonly notificationRepository: INotificationRepository,
private readonly logger: Logger,
) {}
async execute(
input: GetAllNotificationsInput,
): Promise<Result<GetAllNotificationsResult, ApplicationErrorCode<GetAllNotificationsErrorCode, { message: string }>>> {
const { recipientId } = input;
this.logger.debug(
`Attempting to retrieve all notifications for recipient ID: ${recipientId}`,
);
try {
const notifications = await this.notificationRepository.findByRecipientId(
recipientId,
);
this.logger.info(
`Successfully retrieved ${notifications.length} notifications for recipient ID: ${recipientId}`,
);
return Result.ok<GetAllNotificationsResult, ApplicationErrorCode<GetAllNotificationsErrorCode, { message: string }>>({
notifications,
totalCount: notifications.length,
});
} catch (error) {
const err = error instanceof Error ? error : new Error(String(error));
this.logger.error(
`Failed to retrieve notifications for recipient ID: ${recipientId}`,
err,
);
return Result.err<GetAllNotificationsResult, ApplicationErrorCode<GetAllNotificationsErrorCode, { message: string }>>({
code: 'REPOSITORY_ERROR',
details: { message: err.message },
});
}
}
}