services refactor

This commit is contained in:
2025-12-17 22:17:02 +01:00
parent 26f7a2b6aa
commit 055a7f67b5
93 changed files with 7434 additions and 659 deletions

View File

@@ -1,17 +1,54 @@
import { api as api } from '../../api';
import { AuthApiClient } from '../../api/auth/AuthApiClient';
import type { LoginParamsDto, SignupParamsDto, SessionDataDto } from '../../dtos';
export async function signup(params: any): Promise<any> {
return await api.auth.signup(params);
}
/**
* Auth Service
*
* Orchestrates authentication operations by coordinating API calls.
* All dependencies are injected via constructor.
*/
export class AuthService {
constructor(
private readonly apiClient: AuthApiClient
) {}
export async function login(params: any): Promise<any> {
return await api.auth.login(params);
}
/**
* Sign up a new user
*/
async signup(params: SignupParamsDto): Promise<SessionDataDto> {
try {
return await this.apiClient.signup(params);
} catch (error) {
throw error;
}
}
export async function logout(): Promise<void> {
await api.auth.logout();
}
/**
* Log in an existing user
*/
async login(params: LoginParamsDto): Promise<SessionDataDto> {
try {
return await this.apiClient.login(params);
} catch (error) {
throw error;
}
}
export function getIracingAuthUrl(returnTo?: string): string {
return api.auth.getIracingAuthUrl(returnTo);
/**
* Log out the current user
*/
async logout(): Promise<void> {
try {
await this.apiClient.logout();
} catch (error) {
throw error;
}
}
/**
* Get iRacing authentication URL
*/
getIracingAuthUrl(returnTo?: string): string {
return this.apiClient.getIracingAuthUrl(returnTo);
}
}