import { NotFoundError } from "@/src/entities/errors/common" import { IUsersRepository } from "../../repositories/users.repository" import { IInstrumentationService } from "../../services/instrumentation.service.interface" import { UserResponse } from "@/src/entities/models/users/users.model" export type IGetCurrentUserUseCase = ReturnType export const getCurrentUserUseCase = ( instrumentationService: IInstrumentationService, usersRepository: IUsersRepository ) => async (): Promise => { return await instrumentationService.startSpan({ name: "getCurrentUser Use Case", op: "function" }, async () => { const existingUser = await usersRepository.getCurrentUser() if (!existingUser) { throw new NotFoundError("User not found") } return { ...existingUser } } ) }