refactor
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { Provider } from '@nestjs/common';
|
||||
import { DashboardService } from './DashboardService';
|
||||
|
||||
// Import core interfaces
|
||||
import type { Logger } from '@core/shared/application/Logger';
|
||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
||||
import type { DashboardOverviewResult } from '@core/racing/application/use-cases/DashboardOverviewUseCase';
|
||||
import { IDriverRepository } from '@core/racing/domain/repositories/IDriverRepository';
|
||||
import { IRaceRepository } from '@core/racing/domain/repositories/IRaceRepository';
|
||||
import { IResultRepository } from '@core/racing/domain/repositories/IResultRepository';
|
||||
@@ -12,7 +13,8 @@ import { ILeagueMembershipRepository } from '@core/racing/domain/repositories/IL
|
||||
import { IRaceRegistrationRepository } from '@core/racing/domain/repositories/IRaceRegistrationRepository';
|
||||
import { IFeedRepository } from '@core/social/domain/repositories/IFeedRepository';
|
||||
import { ISocialGraphRepository } from '@core/social/domain/repositories/ISocialGraphRepository';
|
||||
import { IImageServicePort } from '@core/racing/application/ports/IImageServicePort';
|
||||
import { ImageServicePort } from '@core/media/application/ports/ImageServicePort';
|
||||
import { DashboardOverviewUseCase } from '@core/racing/application/use-cases/DashboardOverviewUseCase';
|
||||
|
||||
// Import concrete implementations
|
||||
import { ConsoleLogger } from '@adapters/logging/ConsoleLogger';
|
||||
@@ -24,25 +26,31 @@ import { InMemoryStandingRepository } from '@adapters/racing/persistence/inmemor
|
||||
import { InMemoryLeagueMembershipRepository } from '@adapters/racing/persistence/inmemory/InMemoryLeagueMembershipRepository';
|
||||
import { InMemoryRaceRegistrationRepository } from '@adapters/racing/persistence/inmemory/InMemoryRaceRegistrationRepository';
|
||||
import { InMemoryImageServiceAdapter } from '@adapters/media/ports/InMemoryImageServiceAdapter';
|
||||
import { DashboardOverviewPresenter } from './presenters/DashboardOverviewPresenter';
|
||||
|
||||
// Simple mock implementations for missing adapters
|
||||
class MockFeedRepository implements IFeedRepository {
|
||||
async getFeedForDriver(driverId: string, limit?: number) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async getFeedForDriver(_driverId: string, _limit?: number) {
|
||||
return [];
|
||||
}
|
||||
async getGlobalFeed(limit?: number) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async getGlobalFeed(_limit?: number) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
class MockSocialGraphRepository implements ISocialGraphRepository {
|
||||
async getFriends(driverId: string) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async getFriends(_driverId: string) {
|
||||
return [];
|
||||
}
|
||||
async getFriendIds(driverId: string) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async getFriendIds(_driverId: string) {
|
||||
return [];
|
||||
}
|
||||
async getSuggestedFriends(driverId: string, limit?: number) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async getSuggestedFriends(_driverId: string, _limit?: number) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -59,8 +67,11 @@ export const RACE_REGISTRATION_REPOSITORY_TOKEN = 'IRaceRegistrationRepository';
|
||||
export const FEED_REPOSITORY_TOKEN = 'IFeedRepository';
|
||||
export const SOCIAL_GRAPH_REPOSITORY_TOKEN = 'ISocialGraphRepository';
|
||||
export const IMAGE_SERVICE_TOKEN = 'IImageServicePort';
|
||||
export const DASHBOARD_OVERVIEW_USE_CASE_TOKEN = 'DashboardOverviewUseCase';
|
||||
export const DASHBOARD_OVERVIEW_OUTPUT_PORT_TOKEN = 'DashboardOverviewOutputPort';
|
||||
|
||||
export const DashboardProviders: Provider[] = [
|
||||
DashboardOverviewPresenter,
|
||||
{
|
||||
provide: LOGGER_TOKEN,
|
||||
useClass: ConsoleLogger,
|
||||
@@ -113,4 +124,51 @@ export const DashboardProviders: Provider[] = [
|
||||
useFactory: (logger: Logger) => new InMemoryImageServiceAdapter(logger),
|
||||
inject: [LOGGER_TOKEN],
|
||||
},
|
||||
{
|
||||
provide: DASHBOARD_OVERVIEW_OUTPUT_PORT_TOKEN,
|
||||
useExisting: DashboardOverviewPresenter,
|
||||
},
|
||||
{
|
||||
provide: DASHBOARD_OVERVIEW_USE_CASE_TOKEN,
|
||||
useFactory: (
|
||||
driverRepo: IDriverRepository,
|
||||
raceRepo: IRaceRepository,
|
||||
resultRepo: IResultRepository,
|
||||
leagueRepo: ILeagueRepository,
|
||||
standingRepo: IStandingRepository,
|
||||
membershipRepo: ILeagueMembershipRepository,
|
||||
registrationRepo: IRaceRegistrationRepository,
|
||||
feedRepo: IFeedRepository,
|
||||
socialRepo: ISocialGraphRepository,
|
||||
imageService: ImageServicePort,
|
||||
output: UseCaseOutputPort<DashboardOverviewResult>,
|
||||
) =>
|
||||
new DashboardOverviewUseCase(
|
||||
driverRepo,
|
||||
raceRepo,
|
||||
resultRepo,
|
||||
leagueRepo,
|
||||
standingRepo,
|
||||
membershipRepo,
|
||||
registrationRepo,
|
||||
feedRepo,
|
||||
socialRepo,
|
||||
async (driverId: string) => imageService.getDriverAvatar(driverId),
|
||||
() => null,
|
||||
output,
|
||||
),
|
||||
inject: [
|
||||
DRIVER_REPOSITORY_TOKEN,
|
||||
RACE_REPOSITORY_TOKEN,
|
||||
RESULT_REPOSITORY_TOKEN,
|
||||
LEAGUE_REPOSITORY_TOKEN,
|
||||
STANDING_REPOSITORY_TOKEN,
|
||||
LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN,
|
||||
RACE_REGISTRATION_REPOSITORY_TOKEN,
|
||||
FEED_REPOSITORY_TOKEN,
|
||||
SOCIAL_GRAPH_REPOSITORY_TOKEN,
|
||||
IMAGE_SERVICE_TOKEN,
|
||||
DASHBOARD_OVERVIEW_OUTPUT_PORT_TOKEN,
|
||||
],
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user