website refactor
This commit is contained in:
@@ -1,23 +1,25 @@
|
||||
import { AuthApiClient } from '@/lib/api/auth/AuthApiClient';
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { DomainError, Service } from '@/lib/contracts/services/Service';
|
||||
import { AuthService } from './AuthService';
|
||||
import type { AuthSessionDTO } from '@/lib/types/generated/AuthSessionDTO';
|
||||
import { SessionViewModel } from '@/lib/view-models/SessionViewModel';
|
||||
|
||||
/**
|
||||
* Session Service
|
||||
*
|
||||
* Returns SessionViewModel for client consumption.
|
||||
* Orchestrates session-related operations.
|
||||
* Returns raw API DTOs. No ViewModels or UX logic.
|
||||
*/
|
||||
export class SessionService {
|
||||
constructor(
|
||||
private readonly apiClient: AuthApiClient
|
||||
) {}
|
||||
export class SessionService implements Service {
|
||||
private authService: AuthService;
|
||||
|
||||
constructor() {
|
||||
this.authService = new AuthService();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current user session (returns ViewModel)
|
||||
* Get current user session
|
||||
*/
|
||||
async getSession(): Promise<SessionViewModel | null> {
|
||||
const dto = await this.apiClient.getSession();
|
||||
if (!dto) return null;
|
||||
return new SessionViewModel(dto.user);
|
||||
async getSession(): Promise<Result<AuthSessionDTO | null, DomainError>> {
|
||||
return this.authService.getSession();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user