52 lines
1.9 KiB
TypeScript
52 lines
1.9 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
|
|
import { LoggingModule } from '../../domain/logging/LoggingModule';
|
|
|
|
import type { Logger } from '@core/shared/domain/Logger';
|
|
|
|
import type { AvatarGenerationRepository } from '@core/media/domain/repositories/AvatarGenerationRepository';
|
|
import type { AvatarRepository } from '@core/media/domain/repositories/AvatarRepository';
|
|
import type { MediaRepository } from '@core/media/domain/repositories/MediaRepository';
|
|
|
|
import { InMemoryAvatarGenerationRepository } from '@adapters/media/persistence/inmemory/InMemoryAvatarGenerationRepository';
|
|
|
|
import { AVATAR_GENERATION_REPOSITORY_TOKEN, AVATAR_REPOSITORY_TOKEN, MEDIA_REPOSITORY_TOKEN } from '../media/MediaPersistenceTokens';
|
|
|
|
// Mock implementations for Media and Avatar repositories (inmemory only has AvatarGeneration)
|
|
class MockMediaRepository implements MediaRepository {
|
|
async save(): Promise<void> {}
|
|
async findById(): Promise<null> { return null; }
|
|
async findByUploadedBy(): Promise<[]> { return []; }
|
|
async delete(): Promise<void> {}
|
|
}
|
|
|
|
class MockAvatarRepository implements AvatarRepository {
|
|
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): AvatarGenerationRepository =>
|
|
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 {}
|