fix: optimize amenity controller for readability and consistency#25
Open
1234-ad wants to merge 1 commit intoguptapratykshh:branch1from
Open
fix: optimize amenity controller for readability and consistency#251234-ad wants to merge 1 commit intoguptapratykshh:branch1from
1234-ad wants to merge 1 commit intoguptapratykshh:branch1from
Conversation
- Add standardized response handlers (handleError, handleSuccess) - Introduce constants for booking status validation - Add comprehensive JSDoc comments for all functions - Implement consistent error handling across all methods - Add success/failure flags in responses - Use Promise.all for parallel operations in deleteAmenity - Add runValidators option to findByIdAndUpdate - Include valid status options in error responses - Improve code organization and maintainability Resolves guptapratykshh#20
|
@1234-ad is attempting to deploy a commit to the pg999999's projects Team on Vercel. A member of the Team first needs to authorize it. |
✅ Deploy Preview for gatednet canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Resolves Issue
Closes #20
📝 Changes Made
Code Quality Improvements
handleError()andhandleSuccess()helper functions for consistent API responsesBOOKING_STATUSandVALID_STATUSESconstants to eliminate magic stringssuccessboolean flag for easier client-side handlingPerformance Optimizations
Promise.all()indeleteAmenity()to delete bookings and amenity simultaneouslyrunValidators: trueoption tofindByIdAndUpdate()for data integrityDeveloper Experience
🔍 Code Comparison
Before: Repetitive error handling, inconsistent responses, no documentation
After: DRY principles, standardized responses, comprehensive documentation
✅ Testing Checklist
datafield)📸 Benefits