inmemory to postgres

This commit is contained in:
2025-12-29 20:50:03 +01:00
parent 12ae6e1dad
commit 3f610c1cb6
64 changed files with 3689 additions and 63 deletions

View File

@@ -0,0 +1,51 @@
import { Module } from '@nestjs/common';
import { LoggingModule } from '../../domain/logging/LoggingModule';
import type { Logger } from '@core/shared/application/Logger';
import type { IAvatarGenerationRepository } from '@core/media/domain/repositories/IAvatarGenerationRepository';
import type { IMediaRepository } from '@core/media/domain/repositories/IMediaRepository';
import type { IAvatarRepository } from '@core/media/domain/repositories/IAvatarRepository';
import { InMemoryAvatarGenerationRepository } from '@adapters/media/persistence/inmemory/InMemoryAvatarGenerationRepository';
import { AVATAR_GENERATION_REPOSITORY_TOKEN, MEDIA_REPOSITORY_TOKEN, AVATAR_REPOSITORY_TOKEN } from '../media/MediaPersistenceTokens';
// Mock implementations for Media and Avatar repositories (inmemory only has AvatarGeneration)
class MockMediaRepository implements IMediaRepository {
async save(): Promise<void> {}
async findById(): Promise<null> { return null; }
async findByUploadedBy(): Promise<[]> { return []; }
async delete(): Promise<void> {}
}
class MockAvatarRepository implements IAvatarRepository {
async save(): Promise<void> {}
async findById(): Promise<null> { return null; }
async findActiveByDriverId(): Promise<null> { return null; }
async findByDriverId(): Promise<[]> { return []; }
async delete(): Promise<void> {}
}
@Module({
imports: [LoggingModule],
providers: [
{
provide: AVATAR_GENERATION_REPOSITORY_TOKEN,
useFactory: (logger: Logger): IAvatarGenerationRepository =>
new InMemoryAvatarGenerationRepository(logger),
inject: ['Logger'],
},
{
provide: MEDIA_REPOSITORY_TOKEN,
useClass: MockMediaRepository,
},
{
provide: AVATAR_REPOSITORY_TOKEN,
useClass: MockAvatarRepository,
},
],
exports: [AVATAR_GENERATION_REPOSITORY_TOKEN, MEDIA_REPOSITORY_TOKEN, AVATAR_REPOSITORY_TOKEN],
})
export class InMemoryMediaPersistenceModule {}