view models
This commit is contained in:
@@ -1,28 +1,22 @@
|
||||
import { AuthApiClient } from '../../api/auth/AuthApiClient';
|
||||
import { SessionPresenter } from '../../presenters/SessionPresenter';
|
||||
import type { SessionViewModel } from '../../view-models';
|
||||
import { SessionViewModel } from '../../view-models';
|
||||
|
||||
/**
|
||||
* Session Service
|
||||
*
|
||||
* Orchestrates session operations by coordinating API calls and presentation logic.
|
||||
* Orchestrates session operations by coordinating API calls and view model creation.
|
||||
* All dependencies are injected via constructor.
|
||||
*/
|
||||
export class SessionService {
|
||||
constructor(
|
||||
private readonly apiClient: AuthApiClient,
|
||||
private readonly presenter: SessionPresenter
|
||||
private readonly apiClient: AuthApiClient
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Get current user session with presentation transformation
|
||||
* Get current user session with view model transformation
|
||||
*/
|
||||
async getSession(): Promise<SessionViewModel | null> {
|
||||
try {
|
||||
const dto = await this.apiClient.getSession();
|
||||
return this.presenter.presentSession(dto);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
const dto = await this.apiClient.getSession();
|
||||
return dto ? new SessionViewModel(dto) : null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user