mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
refactor: composition root for personal dashboard service (#8280)
This commit is contained in:
parent
6655b2d961
commit
829fda77fd
@ -11,3 +11,4 @@ export * from './events/createEventsService';
|
|||||||
export * from './instance-stats/createInstanceStatsService';
|
export * from './instance-stats/createInstanceStatsService';
|
||||||
export * from './feature-lifecycle/createFeatureLifecycle';
|
export * from './feature-lifecycle/createFeatureLifecycle';
|
||||||
export * from './playground/createPlaygroundService';
|
export * from './playground/createPlaygroundService';
|
||||||
|
export * from './personal-dashboard/createPersonalDashboardService';
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
import type { Db } from '../../db/db';
|
||||||
|
import type { IUnleashConfig } from '../../types';
|
||||||
|
import { PersonalDashboardService } from './personal-dashboard-service';
|
||||||
|
import { PersonalDashboardReadModel } from './personal-dashboard-read-model';
|
||||||
|
import { FakePersonalDashboardReadModel } from './fake-personal-dashboard-read-model';
|
||||||
|
import { ProjectOwnersReadModel } from '../project/project-owners-read-model';
|
||||||
|
import { FakeProjectOwnersReadModel } from '../project/fake-project-owners-read-model';
|
||||||
|
import { ProjectReadModel } from '../project/project-read-model';
|
||||||
|
import { FakeProjectReadModel } from '../project/fake-project-read-model';
|
||||||
|
|
||||||
|
export const createPersonalDashboardService = (
|
||||||
|
db: Db,
|
||||||
|
config: IUnleashConfig,
|
||||||
|
) => {
|
||||||
|
return new PersonalDashboardService(
|
||||||
|
new PersonalDashboardReadModel(db),
|
||||||
|
new ProjectOwnersReadModel(db),
|
||||||
|
new ProjectReadModel(db, config.eventBus, config.flagResolver),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const createFakePersonalDashboardService = () => {
|
||||||
|
return new PersonalDashboardService(
|
||||||
|
new FakePersonalDashboardReadModel(),
|
||||||
|
new FakeProjectOwnersReadModel(),
|
||||||
|
new FakeProjectReadModel(),
|
||||||
|
);
|
||||||
|
};
|
@ -147,12 +147,10 @@ import {
|
|||||||
} from '../features/onboarding/createOnboardingService';
|
} from '../features/onboarding/createOnboardingService';
|
||||||
import { OnboardingService } from '../features/onboarding/onboarding-service';
|
import { OnboardingService } from '../features/onboarding/onboarding-service';
|
||||||
import { PersonalDashboardService } from '../features/personal-dashboard/personal-dashboard-service';
|
import { PersonalDashboardService } from '../features/personal-dashboard/personal-dashboard-service';
|
||||||
import { PersonalDashboardReadModel } from '../features/personal-dashboard/personal-dashboard-read-model';
|
import {
|
||||||
import { FakePersonalDashboardReadModel } from '../features/personal-dashboard/fake-personal-dashboard-read-model';
|
createFakePersonalDashboardService,
|
||||||
import { ProjectOwnersReadModel } from '../features/project/project-owners-read-model';
|
createPersonalDashboardService,
|
||||||
import { FakeProjectOwnersReadModel } from '../features/project/fake-project-owners-read-model';
|
} from '../features/personal-dashboard/createPersonalDashboardService';
|
||||||
import { FakeProjectReadModel } from '../features/project/fake-project-read-model';
|
|
||||||
import { ProjectReadModel } from '../features/project/project-read-model';
|
|
||||||
|
|
||||||
export const createServices = (
|
export const createServices = (
|
||||||
stores: IUnleashStores,
|
stores: IUnleashStores,
|
||||||
@ -408,17 +406,9 @@ export const createServices = (
|
|||||||
: createFakeOnboardingService(config).onboardingService;
|
: createFakeOnboardingService(config).onboardingService;
|
||||||
onboardingService.listen();
|
onboardingService.listen();
|
||||||
|
|
||||||
// TODO: move to composition root
|
const personalDashboardService = db
|
||||||
const personalDashboardService = new PersonalDashboardService(
|
? createPersonalDashboardService(db, config)
|
||||||
db
|
: createFakePersonalDashboardService();
|
||||||
? new PersonalDashboardReadModel(db)
|
|
||||||
: new FakePersonalDashboardReadModel(),
|
|
||||||
|
|
||||||
db ? new ProjectOwnersReadModel(db) : new FakeProjectOwnersReadModel(),
|
|
||||||
db
|
|
||||||
? new ProjectReadModel(db, config.eventBus, config.flagResolver)
|
|
||||||
: new FakeProjectReadModel(),
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
accessService,
|
accessService,
|
||||||
|
Loading…
Reference in New Issue
Block a user