architecture refactoring

This commit is contained in:
Cesar
2026-05-22 19:26:38 -06:00
parent 34dbfd051b
commit c2e53eb21b
20 changed files with 949 additions and 222 deletions

View File

@@ -0,0 +1,30 @@
/**
* get-me.use-case.ts
* GetMeUseCase: obtiene los datos del usuario autenticado.
* - Busca el usuario por ID (que viene del JWT)
* - Retorna los datos del usuario
*/
import { AuthRepository } from "../../repositories/auth.repository.js";
import { CustomError } from "../../errors/custom.error.js";
export interface GetMeResponse {
id: number;
email: string;
name: string;
role: string;
}
export class GetMeUseCase {
constructor(private repository: AuthRepository) {}
async execute(userId: number): Promise<GetMeResponse> {
const user = await this.repository.findById(userId);
if (!user) {
throw CustomError.notFound("User not found");
}
return user as GetMeResponse;
}
}