24 lines
637 B
TypeScript
24 lines
637 B
TypeScript
import { AuthApiClient } from '@/lib/api/auth/AuthApiClient';
|
|
import type { AuthSessionDTO } from '@/lib/types/generated/AuthSessionDTO';
|
|
import { SessionViewModel } from '@/lib/view-models/SessionViewModel';
|
|
|
|
/**
|
|
* Session Service
|
|
*
|
|
* Returns SessionViewModel for client consumption.
|
|
*/
|
|
export class SessionService {
|
|
constructor(
|
|
private readonly apiClient: AuthApiClient
|
|
) {}
|
|
|
|
/**
|
|
* Get current user session (returns ViewModel)
|
|
*/
|
|
async getSession(): Promise<SessionViewModel | null> {
|
|
const dto = await this.apiClient.getSession();
|
|
if (!dto) return null;
|
|
return new SessionViewModel(dto.user);
|
|
}
|
|
}
|