@@ -12,7 +12,7 @@ const getAllVaccination = async (req, res, next) => {
1212 query ,
1313 ) ;
1414
15- res . status ( 200 ) . json ( { vaccinations, sucess : true } ) ;
15+ res . status ( 200 ) . json ( { vaccinations } ) ;
1616 } catch ( error ) {
1717 next ( error ) ;
1818 }
@@ -38,7 +38,7 @@ const createVaccination = async (req, res, next) => {
3838 res . status ( 201 ) . json ( {
3939 message : 'Vaccination was successfully created' ,
4040 success : true ,
41- newVaccination : formattedVaccinationData ,
41+ vaccination : formattedVaccinationData ,
4242 } ) ;
4343 } catch ( error ) {
4444 next ( error ) ;
@@ -56,8 +56,7 @@ const updateVaccination = async (req, res, next) => {
5656 vaccinationId ,
5757 vaccinationData ,
5858 ) ;
59- if ( ! updatedVaccination ?. id )
60- throw Boom . badRequest ( 'Update animal operation returns null' ) ;
59+
6160 const formattedVaccinationData = await vaccinationService . getVaccination (
6261 userId ,
6362 updatedVaccination . id ,
@@ -66,7 +65,7 @@ const updateVaccination = async (req, res, next) => {
6665 res . status ( 200 ) . json ( {
6766 message : 'Vaccination was successfully updated' ,
6867 success : true ,
69- updatedVaccination : formattedVaccinationData ,
68+ vaccination : formattedVaccinationData ,
7069 } ) ;
7170 } catch ( error ) {
7271 next ( error ) ;
@@ -78,17 +77,15 @@ const deleteVaccination = async (req, res, next) => {
7877 const { vaccinationId } = req . params ;
7978 const userId = req . user . sub ;
8079
81- const deletedVaccination = await vaccinationService . deleteVaccination (
80+ const affectedRows = await vaccinationService . deleteVaccination (
8281 userId ,
8382 vaccinationId ,
8483 ) ;
85- if ( deletedVaccination === 0 )
86- throw Boom . badRequest ( 'Delete animal operation returns 0 rows affected' ) ;
8784
8885 res . status ( 200 ) . json ( {
8986 message : 'Vaccination was successfully deleted' ,
9087 success : true ,
91- deletedVaccination ,
88+ affectedRows ,
9289 } ) ;
9390 } catch ( error ) {
9491 next ( error ) ;
0 commit comments