singhsanket143 / Flights-Service

38 stars 18 forks source link

Implement Delete City Api #2

Open singhsanket143 opened 1 year ago

singhsanket143 commented 1 year ago

We need to implement delete city api with the following signature /api/v1/cities/:id - DELETE Req Body: {}

Do handle the error scenario as well when we dont find a record to update

swraj28 commented 1 year ago

I have created a PR regarding this issue . Please look into it .

shubhamkhuntia commented 1 year ago

Please review & let me know

CITY ROUTE

router.delete("/:id", CityController.deleteCity);

CITY CONTROLLER

async function deleteCity(req, res) { try { const city = await CityService.deleteCity(req.params.id); return city; } catch (error) { ErrorResponse.error = error; return res.status(error.statusCode).json(ErrorResponse); } }

CITY SERVICE

async function deleteCity(id) { try { const response = await cityRepository.destroy(id); return response; } catch (error) { if (error.statusCode == StatusCodes.NOT_FOUND) { throw new AppError( "The city you requested to delete is not present", error.statusCode ); } throw new AppError("Cannnot delete city", statusCode.INTERNAL_SERVER_ERROR); } }

Sk-Shubhasheesh commented 1 year ago

DONE

Itsayush30 commented 9 months ago

Done it is!!!

SuryaTanwar commented 7 months ago

Done :)