Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE #216 Updated campgrounds.js #217

Open
wants to merge 1 commit into
base: test
Choose a base branch
from

Conversation

Sumanth077s
Copy link

📋 Description

This pull request addresses the need for better documentation, code structure, and error handling in the Campground controller. The goal is to enhance readability, maintainability, and overall code quality, making it easier for future developers to work with this module.

🔨 Changes Made

Improved Documentation:

Enhanced JSDoc comments for all exported functions, providing details on parameters, return types, and potential exceptions.
Added a module description at the top of the file explaining the purpose and functionality of the Campground controller.
Refactored Code Structure:

Extracted the average rating calculation into a utility function located in a new utils.js file for better code reusability and adherence to the DRY principle.
Organized related functionalities into separate modules to improve separation of concerns, including a new module for handling geocoding and image processing.
Consistent Error Handling:

Standardized error handling across all methods using ExpressError to provide clearer feedback to users.
Implemented checks for required parameters in createCampground and updateCampground methods to handle potential issues gracefully.
Improved Variable Naming:

Renamed ambiguous variable q in the searchCampgrounds method to query for better clarity and understanding.
Performance Optimizations:

Used .select() in database queries to limit the fields returned, thereby reducing data transfer when unnecessary.

✅ Checklist

Before submitting the PR, please make sure you have completed the following:

  • [y ] My code follows the style guidelines of this project.
  • [ y] I have performed a self-review of my own code.
  • [y ] I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation (if applicable).
  • [y ] My changes generate no new warnings.
  • I have tested it locally and it works fine.
  • Any dependent changes have been merged and published in downstream modules.

🏷️ Types of Changes

What type of changes does your code introduce? (Check all that apply)

  • Bug fix (non-breaking change which fixes an issue) 🐛
  • New feature (non-breaking change which adds functionality) ✨
  • UI enhancement (non-breaking change which enhances UI) 🎨
  • [y ] Documentation update 📚

🤝 Related Issues

📸 Screenshots (if applicable)


Reminder:

Please ensure your pull request is made to the test branch, not main.

Thank you for contributing to VigneshDevHub! We look forward to reviewing your PR and getting it merged!

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Thank you for your contribution! Your pull request has been submitted successfully. A maintainer will review it as soon as possible. Support us by ⭐starring our repository!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant