refactor: revew all design of services, clients, deadcode, ...

This commit is contained in:
Julien Froidefond
2025-08-24 22:03:15 +02:00
parent f4dcc89c11
commit 6fba622003
63 changed files with 969 additions and 1846 deletions

View File

@@ -0,0 +1,33 @@
import { BaseHttpClient } from "../base/http-client";
import { UserProfile } from "../../lib/types";
export class AuthClient extends BaseHttpClient {
/**
* Authentifie un utilisateur et créé le cookie
*/
async login(
profile: UserProfile
): Promise<{ user: UserProfile & { uuid: string }; userUuid: string }> {
return await this.post("/auth", profile);
}
/**
* Récupère l'utilisateur actuel depuis le cookie
*/
async getCurrentUser(): Promise<UserProfile | null> {
try {
const response = await this.get<{ user: UserProfile }>("/auth");
return response.user;
} catch (error) {
console.error("Failed to get current user:", error);
return null;
}
}
/**
* Déconnecte l'utilisateur (supprime le cookie)
*/
async logout(): Promise<void> {
await this.delete("/auth");
}
}