harden media

This commit is contained in:
2025-12-31 15:39:28 +01:00
parent 92226800df
commit 8260bf7baf
413 changed files with 8361 additions and 1544 deletions

View File

@@ -2,7 +2,7 @@
* Infrastructure Adapter: InMemoryMediaRepository
*
* In-memory implementation of IMediaRepository.
* Stores URLs for static media assets like logos and images.
* Stores URLs for media assets like avatars and logos.
*/
import type { IMediaRepository } from '@core/racing/domain/repositories/IMediaRepository';
@@ -11,9 +11,8 @@ import type { Logger } from '@core/shared/application';
export class InMemoryMediaRepository implements IMediaRepository {
private driverAvatars = new Map<string, string>();
private teamLogos = new Map<string, string>();
private trackImages = new Map<string, string>();
private categoryIcons = new Map<string, string>();
private sponsorLogos = new Map<string, string>();
private leagueLogos = new Map<string, string>();
private leagueCovers = new Map<string, string>();
constructor(private readonly logger: Logger) {
this.logger.info('[InMemoryMediaRepository] Initialized.');
@@ -27,16 +26,12 @@ export class InMemoryMediaRepository implements IMediaRepository {
return this.teamLogos.get(teamId) ?? null;
}
async getTrackImage(trackId: string): Promise<string | null> {
return this.trackImages.get(trackId) ?? null;
async getLeagueLogo(leagueId: string): Promise<string | null> {
return this.leagueLogos.get(leagueId) ?? null;
}
async getCategoryIcon(categoryId: string): Promise<string | null> {
return this.categoryIcons.get(categoryId) ?? null;
}
async getSponsorLogo(sponsorId: string): Promise<string | null> {
return this.sponsorLogos.get(sponsorId) ?? null;
async getLeagueCover(leagueId: string): Promise<string | null> {
return this.leagueCovers.get(leagueId) ?? null;
}
// Helper methods for seeding
@@ -48,23 +43,18 @@ export class InMemoryMediaRepository implements IMediaRepository {
this.teamLogos.set(teamId, url);
}
setTrackImage(trackId: string, url: string): void {
this.trackImages.set(trackId, url);
setLeagueLogo(leagueId: string, url: string): void {
this.leagueLogos.set(leagueId, url);
}
setCategoryIcon(categoryId: string, url: string): void {
this.categoryIcons.set(categoryId, url);
}
setSponsorLogo(sponsorId: string, url: string): void {
this.sponsorLogos.set(sponsorId, url);
setLeagueCover(leagueId: string, url: string): void {
this.leagueCovers.set(leagueId, url);
}
async clear(): Promise<void> {
this.driverAvatars.clear();
this.teamLogos.clear();
this.trackImages.clear();
this.categoryIcons.clear();
this.sponsorLogos.clear();
this.leagueLogos.clear();
this.leagueCovers.clear();
}
}
}