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,9 +1,28 @@
import { api as api } from '../../api';
import { SessionViewModel } from '../../view-models';
import { AuthApiClient } from '../../api/auth/AuthApiClient';
import { SessionPresenter } from '../../presenters/SessionPresenter';
import type { SessionViewModel } from '../../view-models';
export async function getSession(): Promise<SessionViewModel | null> {
const dto = await api.auth.getSession();
if (!dto) return null;
// TODO: presenter
return dto as any;
/**
* 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;
}
}
}