Open singhsanket143 opened 1 year ago
I have created a PR regarding this issue . Please look into it .
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); } }
DONE
Done it is!!!
Done :)
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