14 lines
425 B
TypeScript
14 lines
425 B
TypeScript
import { User } from '../../domain/entities/User';
|
|
import { IUserRepository } from '../../domain/repositories/IUserRepository';
|
|
|
|
export class GetUserUseCase {
|
|
constructor(private userRepo: IUserRepository) {}
|
|
|
|
async execute(userId: string): Promise<User> {
|
|
const stored = await this.userRepo.findById(userId);
|
|
if (!stored) {
|
|
throw new Error('User not found');
|
|
}
|
|
return User.fromStored(stored);
|
|
}
|
|
} |