website refactor

This commit is contained in:
2026-01-16 21:57:44 +01:00
parent 83a9092c50
commit 27f5a52e04
30 changed files with 166 additions and 161 deletions

View File

@@ -17,8 +17,8 @@ export class InMemoryNotificationRepository implements NotificationRepository {
this.logger = logger;
this.logger.info('InMemoryNotificationRepository initialized.');
initialNotifications.forEach(notification => {
this.notifications.set(notification.id, notification);
this.logger.debug(`Seeded notification: ${notification.id}`);
this.notifications.set(notification.id.value, notification);
this.logger.debug(`Seeded notification: ${notification.id.value}`);
});
}
@@ -95,31 +95,31 @@ export class InMemoryNotificationRepository implements NotificationRepository {
}
async create(notification: Notification): Promise<void> {
this.logger.debug(`Creating notification: ${notification.id}`);
this.logger.debug(`Creating notification: ${notification.id.value}`);
try {
if (this.notifications.has(notification.id)) {
this.logger.warn(`Notification with ID ${notification.id} already exists. Throwing error.`);
throw new Error(`Notification with ID ${notification.id} already exists`);
if (this.notifications.has(notification.id.value)) {
this.logger.warn(`Notification with ID ${notification.id.value} already exists. Throwing error.`);
throw new Error(`Notification with ID ${notification.id.value} already exists`);
}
this.notifications.set(notification.id, notification);
this.logger.info(`Notification ${notification.id} created successfully.`);
this.notifications.set(notification.id.value, notification);
this.logger.info(`Notification ${notification.id.value} created successfully.`);
} catch (error) {
this.logger.error(`Error creating notification ${notification.id}:`, error instanceof Error ? error : new Error(String(error)));
this.logger.error(`Error creating notification ${notification.id.value}:`, error instanceof Error ? error : new Error(String(error)));
throw error;
}
}
async update(notification: Notification): Promise<void> {
this.logger.debug(`Updating notification: ${notification.id}`);
this.logger.debug(`Updating notification: ${notification.id.value}`);
try {
if (!this.notifications.has(notification.id)) {
this.logger.warn(`Notification with ID ${notification.id} not found for update. Throwing error.`);
throw new Error(`Notification with ID ${notification.id} not found`);
if (!this.notifications.has(notification.id.value)) {
this.logger.warn(`Notification with ID ${notification.id.value} not found for update. Throwing error.`);
throw new Error(`Notification with ID ${notification.id.value} not found`);
}
this.notifications.set(notification.id, notification);
this.logger.info(`Notification ${notification.id} updated successfully.`);
this.notifications.set(notification.id.value, notification);
this.logger.info(`Notification ${notification.id.value} updated successfully.`);
} catch (error) {
this.logger.error(`Error updating notification ${notification.id}:`, error instanceof Error ? error : new Error(String(error)));
this.logger.error(`Error updating notification ${notification.id.value}:`, error instanceof Error ? error : new Error(String(error)));
throw error;
}
}
@@ -143,7 +143,7 @@ export class InMemoryNotificationRepository implements NotificationRepository {
try {
const toDelete = Array.from(this.notifications.values())
.filter(n => n.recipientId === recipientId)
.map(n => n.id);
.map(n => n.id.value);
toDelete.forEach(id => this.notifications.delete(id));
this.logger.info(`Deleted ${toDelete.length} notifications for recipient ID: ${recipientId}.`);
@@ -163,7 +163,7 @@ export class InMemoryNotificationRepository implements NotificationRepository {
toUpdate.forEach(n => {
const updated = n.markAsRead();
this.notifications.set(updated.id, updated);
this.notifications.set(updated.id.value, updated);
});
this.logger.info(`Marked ${toUpdate.length} notifications as read for recipient ID: ${recipientId}.`);
} catch (error) {