Files
gridpilot.gg/apps/website/lib/services/auth/SessionService.ts
2025-12-17 22:17:02 +01:00

28 lines
802 B
TypeScript

import { AuthApiClient } from '../../api/auth/AuthApiClient';
import { SessionPresenter } from '../../presenters/SessionPresenter';
import type { SessionViewModel } from '../../view-models';
/**
* Session Service
*
* Orchestrates session operations by coordinating API calls and presentation logic.
* All dependencies are injected via constructor.
*/
export class SessionService {
constructor(
private readonly apiClient: AuthApiClient,
private readonly presenter: SessionPresenter
) {}
/**
* Get current user session with presentation transformation
*/
async getSession(): Promise<SessionViewModel | null> {
try {
const dto = await this.apiClient.getSession();
return this.presenter.presentSession(dto);
} catch (error) {
throw error;
}
}
}