refactor use cases
This commit is contained in:
@@ -3,50 +3,31 @@ import { Module } from '@nestjs/common';
|
||||
import { InMemoryAdminPersistenceModule } from '../../persistence/inmemory/InMemoryAdminPersistenceModule';
|
||||
import { AdminService } from './AdminService';
|
||||
import { AdminController } from './AdminController';
|
||||
import { ListUsersPresenter } from './presenters/ListUsersPresenter';
|
||||
import { DashboardStatsPresenter } from './presenters/DashboardStatsPresenter';
|
||||
import { AuthModule } from '../auth/AuthModule';
|
||||
import { ListUsersUseCase } from '@core/admin/application/use-cases/ListUsersUseCase';
|
||||
import { GetDashboardStatsUseCase } from './use-cases/GetDashboardStatsUseCase';
|
||||
import { InitializationLogger } from '../../shared/logging/InitializationLogger';
|
||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
||||
import type { ListUsersResult } from '@core/admin/application/use-cases/ListUsersUseCase';
|
||||
import type { DashboardStatsResult } from './use-cases/GetDashboardStatsUseCase';
|
||||
import type { IAdminUserRepository } from '@core/admin/domain/repositories/IAdminUserRepository';
|
||||
|
||||
export const ADMIN_USER_REPOSITORY_TOKEN = 'IAdminUserRepository';
|
||||
export const LIST_USERS_OUTPUT_PORT_TOKEN = 'ListUsersOutputPort';
|
||||
export const DASHBOARD_STATS_OUTPUT_PORT_TOKEN = 'DashboardStatsOutputPort';
|
||||
|
||||
const initLogger = InitializationLogger.getInstance();
|
||||
|
||||
const adminProviders: Provider[] = [
|
||||
AdminService,
|
||||
ListUsersPresenter,
|
||||
DashboardStatsPresenter,
|
||||
{
|
||||
provide: LIST_USERS_OUTPUT_PORT_TOKEN,
|
||||
useExisting: ListUsersPresenter,
|
||||
},
|
||||
{
|
||||
provide: DASHBOARD_STATS_OUTPUT_PORT_TOKEN,
|
||||
useExisting: DashboardStatsPresenter,
|
||||
},
|
||||
{
|
||||
provide: ListUsersUseCase,
|
||||
useFactory: (
|
||||
repository: IAdminUserRepository,
|
||||
output: UseCaseOutputPort<ListUsersResult>,
|
||||
) => new ListUsersUseCase(repository, output),
|
||||
inject: [ADMIN_USER_REPOSITORY_TOKEN, LIST_USERS_OUTPUT_PORT_TOKEN],
|
||||
) => new ListUsersUseCase(repository),
|
||||
inject: [ADMIN_USER_REPOSITORY_TOKEN],
|
||||
},
|
||||
{
|
||||
provide: GetDashboardStatsUseCase,
|
||||
useFactory: (
|
||||
repository: IAdminUserRepository,
|
||||
output: UseCaseOutputPort<DashboardStatsResult>,
|
||||
) => new GetDashboardStatsUseCase(repository, output),
|
||||
inject: [ADMIN_USER_REPOSITORY_TOKEN, DASHBOARD_STATS_OUTPUT_PORT_TOKEN],
|
||||
) => new GetDashboardStatsUseCase(repository),
|
||||
inject: [ADMIN_USER_REPOSITORY_TOKEN],
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user