This pull request introduces the following functionality for the AttractionSite model:
Get all attraction sites.
Get an attraction site by its ID.
Create a new attraction site.
Update an existing attraction site.
Delete an attraction site.
Search attraction sites by name, category, and location.
Details
Get All Attraction Sites:
GET /attractions: Fetches and returns all attraction sites from the database.
Status: 200 on success, 500 on failure.
Get Attraction Site by ID:
GET /attractions/:id: Fetches a specific attraction site by its ID.
Status: 200 if found, 404 if not found, 500 on failure.
Create New Attraction Site:
POST /attractions: Creates a new attraction site with fields like name, location, description, category, rating, etc.
Status: 201 on successful creation, 500 on failure.
Update Attraction Site:
PUT /attractions/:id: Updates an attraction site with provided data.
Status: 200 on success, 404 if not found, 500 on failure.
Delete Attraction Site:
DELETE /attractions/:id: Deletes an attraction site by ID.
Status: 200 on successful deletion, 404 if not found, 500 on failure.
Search Attraction Sites:
GET /attractions/search?name=&category=&location=: Filters attraction sites based on name, category, and location. Supports partial search using case-insensitive regular expressions.
Status: 200 on success, 500 on failure.
Testing
Ensure all CRUD operations (create, read, update, delete) are working as expected.
Test search functionality for partial matches.
Test for error handling (404 not found, 500 server errors).
Example Endpoints
GET/attractions
GET/attractions/:id
POST/attractions
PUT/attractions/:id
DELETE/attractions/:id
GET/attractions/search?name=Table Mountain&category=adventure&location=Cape Town
Summary
This pull request introduces the following functionality for the
AttractionSite
model:Details
Get All Attraction Sites:
GET /attractions
: Fetches and returns all attraction sites from the database.Get Attraction Site by ID:
GET /attractions/:id
: Fetches a specific attraction site by its ID.Create New Attraction Site:
POST /attractions
: Creates a new attraction site with fields likename
,location
,description
,category
,rating
, etc.Update Attraction Site:
PUT /attractions/:id
: Updates an attraction site with provided data.Delete Attraction Site:
DELETE /attractions/:id
: Deletes an attraction site by ID.Search Attraction Sites:
GET /attractions/search?name=&category=&location=
: Filters attraction sites based onname
,category
, andlocation
. Supports partial search using case-insensitive regular expressions.Testing
Example Endpoints
/attractions
/attractions/:id
/attractions
/attractions/:id
/attractions/:id
/attractions/search?name=Table Mountain&category=adventure&location=Cape Town
Related Issues
Closes #50
Checklist
[x] Code follows the project's coding standards.
[x] Search functionality works as intended.
[x] Proper error handling for all operations.