import { injectable , inject } from 'tsyringe' ; import AppError from '@shared/errors/AppError' ; import IUsersRepository from '../repositories/IUsersRepository' ; import User from '../infra/typeorm/entities/Users' ; interface IRequestDTO { user_id : string ; } @ injectable ( ) export default class ShowProfileService { constructor ( @ inject ( 'UsersRepository' ) private usersRepository ) { } public async execute ( { user_id } ) { const user = await this . usersRepository . findById ( user_id ) ; if ( ! user ) { throw new AppError ( 'User not found.' ) ; } delete user . password ; return user ; } }