Refatora Van para Vehicle

This commit is contained in:
Matheus Albino Brunhara
2022-09-03 19:39:07 -03:00
parent 7ce2e602cc
commit 0ff59fcfea
23 changed files with 368 additions and 469 deletions

View File

@@ -0,0 +1,23 @@
import { getRepository } from 'typeorm';
import AppError from '../errors/AppError';
import Vehicle from '../models/Vehicle';
class FindVehicleService {
public async execute(plate: string): Promise<Vehicle> {
const vehiclesRepository = getRepository(Vehicle);
const vehicle = await vehiclesRepository.findOne({
where: { plate }
});
if (!vehicle) {
throw new AppError('A vehicle informada não existe.');
};
return vehicle;
}
}
export default FindVehicleService;