refactor to adapters
This commit is contained in:
14
core/identity/application/use-cases/GetUserUseCase.ts
Normal file
14
core/identity/application/use-cases/GetUserUseCase.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user