website refactor
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
import { ContainerModule } from 'inversify';
|
||||
import { AuthService } from '../../services/auth/AuthService';
|
||||
import { SessionService } from '../../services/auth/SessionService';
|
||||
import { AuthApiClient } from '../../api/auth/AuthApiClient';
|
||||
|
||||
import {
|
||||
AUTH_SERVICE_TOKEN,
|
||||
SESSION_SERVICE_TOKEN,
|
||||
AUTH_API_CLIENT_TOKEN
|
||||
} from '../tokens';
|
||||
|
||||
export const AuthModule = new ContainerModule((options) => {
|
||||
@@ -14,10 +12,7 @@ export const AuthModule = new ContainerModule((options) => {
|
||||
|
||||
// Session Service
|
||||
bind<SessionService>(SESSION_SERVICE_TOKEN)
|
||||
.toDynamicValue((ctx) => {
|
||||
const authApiClient = ctx.get<AuthApiClient>(AUTH_API_CLIENT_TOKEN);
|
||||
return new SessionService(authApiClient);
|
||||
})
|
||||
.to(SessionService)
|
||||
.inSingletonScope();
|
||||
|
||||
// Auth Service - now creates its own dependencies
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
import { ContainerModule } from 'inversify';
|
||||
import { DRIVER_SERVICE_TOKEN, DRIVER_API_CLIENT_TOKEN, ONBOARDING_SERVICE_TOKEN } from '../tokens';
|
||||
import { DRIVER_SERVICE_TOKEN, ONBOARDING_SERVICE_TOKEN } from '../tokens';
|
||||
import { DriverService } from '@/lib/services/drivers/DriverService';
|
||||
import { OnboardingService } from '@/lib/services/onboarding/OnboardingService';
|
||||
import { DriversApiClient } from '@/lib/api/drivers/DriversApiClient';
|
||||
|
||||
export const DriverModule = new ContainerModule((options) => {
|
||||
const bind = options.bind;
|
||||
|
||||
bind(DRIVER_SERVICE_TOKEN)
|
||||
.toDynamicValue((ctx) => {
|
||||
const apiClient = ctx.get<DriversApiClient>(DRIVER_API_CLIENT_TOKEN);
|
||||
return new DriverService(apiClient);
|
||||
})
|
||||
.to(DriverService)
|
||||
.inSingletonScope();
|
||||
|
||||
bind(ONBOARDING_SERVICE_TOKEN)
|
||||
|
||||
@@ -1,23 +1,12 @@
|
||||
import { ContainerModule } from 'inversify';
|
||||
import { LANDING_SERVICE_TOKEN, RACE_API_CLIENT_TOKEN, LEAGUE_API_CLIENT_TOKEN, TEAM_API_CLIENT_TOKEN, AUTH_API_CLIENT_TOKEN } from '../tokens';
|
||||
import { LANDING_SERVICE_TOKEN } from '../tokens';
|
||||
import { LandingService } from '@/lib/services/landing/LandingService';
|
||||
import { RacesApiClient } from '@/lib/api/races/RacesApiClient';
|
||||
import { LeaguesApiClient } from '@/lib/api/leagues/LeaguesApiClient';
|
||||
import { TeamsApiClient } from '@/lib/api/teams/TeamsApiClient';
|
||||
import { AuthApiClient } from '@/lib/api/auth/AuthApiClient';
|
||||
|
||||
export const LandingModule = new ContainerModule((options) => {
|
||||
const bind = options.bind;
|
||||
|
||||
// Landing Service
|
||||
bind<LandingService>(LANDING_SERVICE_TOKEN)
|
||||
.toDynamicValue((ctx) => {
|
||||
const racesApi = ctx.get<RacesApiClient>(RACE_API_CLIENT_TOKEN);
|
||||
const leaguesApi = ctx.get<LeaguesApiClient>(LEAGUE_API_CLIENT_TOKEN);
|
||||
const teamsApi = ctx.get<TeamsApiClient>(TEAM_API_CLIENT_TOKEN);
|
||||
const authApi = ctx.get<AuthApiClient>(AUTH_API_CLIENT_TOKEN);
|
||||
|
||||
return new LandingService(racesApi, leaguesApi, teamsApi, authApi);
|
||||
})
|
||||
.to(LandingService)
|
||||
.inSingletonScope();
|
||||
});
|
||||
@@ -18,36 +18,26 @@ export const LeagueModule = new ContainerModule((options) => {
|
||||
|
||||
// League Service
|
||||
bind<LeagueService>(LEAGUE_SERVICE_TOKEN)
|
||||
.toDynamicValue(() => {
|
||||
return new LeagueService();
|
||||
})
|
||||
.to(LeagueService)
|
||||
.inSingletonScope();
|
||||
|
||||
// League Settings Service
|
||||
bind<LeagueSettingsService>(LEAGUE_SETTINGS_SERVICE_TOKEN)
|
||||
.toDynamicValue(() => {
|
||||
return new LeagueSettingsService();
|
||||
})
|
||||
.to(LeagueSettingsService)
|
||||
.inSingletonScope();
|
||||
|
||||
// League Stewarding Service
|
||||
bind<LeagueStewardingService>(LEAGUE_STEWARDING_SERVICE_TOKEN)
|
||||
.toDynamicValue(() => {
|
||||
return new LeagueStewardingService();
|
||||
})
|
||||
.to(LeagueStewardingService)
|
||||
.inSingletonScope();
|
||||
|
||||
// League Wallet Service
|
||||
bind<LeagueWalletService>(LEAGUE_WALLET_SERVICE_TOKEN)
|
||||
.toDynamicValue(() => {
|
||||
return new LeagueWalletService();
|
||||
})
|
||||
.to(LeagueWalletService)
|
||||
.inSingletonScope();
|
||||
|
||||
// League Membership Service
|
||||
bind<LeagueMembershipService>(LEAGUE_MEMBERSHIP_SERVICE_TOKEN)
|
||||
.toDynamicValue(() => {
|
||||
return new LeagueMembershipService();
|
||||
})
|
||||
.to(LeagueMembershipService)
|
||||
.inSingletonScope();
|
||||
});
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import { ContainerModule } from 'inversify';
|
||||
import { POLICY_SERVICE_TOKEN, POLICY_API_CLIENT_TOKEN } from '../tokens';
|
||||
import { POLICY_SERVICE_TOKEN } from '../tokens';
|
||||
import { PolicyService } from '@/lib/services/policy/PolicyService';
|
||||
import { PolicyApiClient } from '@/lib/api/policy/PolicyApiClient';
|
||||
|
||||
export const PolicyModule = new ContainerModule((options) => {
|
||||
const bind = options.bind;
|
||||
|
||||
// Policy Service
|
||||
bind<PolicyService>(POLICY_SERVICE_TOKEN)
|
||||
.toDynamicValue((ctx) => {
|
||||
const apiClient = ctx.get<PolicyApiClient>(POLICY_API_CLIENT_TOKEN);
|
||||
return new PolicyService(apiClient);
|
||||
})
|
||||
.to(PolicyService)
|
||||
.inSingletonScope();
|
||||
});
|
||||
@@ -3,17 +3,10 @@ import { RaceService } from '@/lib/services/races/RaceService';
|
||||
import { RaceResultsService } from '@/lib/services/races/RaceResultsService';
|
||||
import { RaceStewardingService } from '@/lib/services/races/RaceStewardingService';
|
||||
|
||||
import { RacesApiClient } from '@/lib/api/races/RacesApiClient';
|
||||
import { ProtestsApiClient } from '@/lib/api/protests/ProtestsApiClient';
|
||||
import { PenaltiesApiClient } from '@/lib/api/penalties/PenaltiesApiClient';
|
||||
|
||||
import {
|
||||
RACE_SERVICE_TOKEN,
|
||||
RACE_RESULTS_SERVICE_TOKEN,
|
||||
RACE_STEWARDING_SERVICE_TOKEN,
|
||||
RACE_API_CLIENT_TOKEN,
|
||||
PROTEST_API_CLIENT_TOKEN,
|
||||
PENALTY_API_CLIENT_TOKEN,
|
||||
} from '../tokens';
|
||||
|
||||
export const RaceModule = new ContainerModule((options) => {
|
||||
@@ -21,10 +14,7 @@ export const RaceModule = new ContainerModule((options) => {
|
||||
|
||||
// Race Service - creates its own dependencies per contract
|
||||
bind<RaceService>(RACE_SERVICE_TOKEN)
|
||||
.toDynamicValue((ctx) => {
|
||||
const raceApiClient = ctx.get<RacesApiClient>(RACE_API_CLIENT_TOKEN);
|
||||
return new RaceService(raceApiClient);
|
||||
})
|
||||
.to(RaceService)
|
||||
.inSingletonScope();
|
||||
|
||||
// Race Results Service - creates its own dependencies per contract
|
||||
|
||||
Reference in New Issue
Block a user