Enhancement : New Endpoint to Retrieve Combined Lost and Found Items#89
Enhancement : New Endpoint to Retrieve Combined Lost and Found Items#89harsh15044 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new combined API endpoint that retrieves both lost and found items in a single response, sorted by creation time. This enhancement provides a unified view of all lost and found items for easier browsing.
- Added
/lost_found/allendpoint with optionalmax_limitquery parameter - Implemented combined retrieval logic that merges lost and found items
- Added sorting by creation time with newest items first
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| backend-go/internal/router/routes.go | Added new route group and endpoint for combined lost/found items |
| backend-go/internal/controller/lost.go | Implemented GetCombinedAllItemsHandler function with sorting and limit functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…edAllItemsHandler
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if limitStr := c.Query("max_limit"); limitStr != "" { | ||
| if limit, err := strconv.Atoi(limitStr); err == nil { | ||
| maxLimit = limit |
There was a problem hiding this comment.
Missing input validation for max_limit parameter. If a user provides a negative value or zero, the code will accept it and could produce unexpected results. Consider adding validation to ensure max_limit is positive, and potentially also adding an upper bound to prevent resource exhaustion from extremely large values.
| if limitStr := c.Query("max_limit"); limitStr != "" { | |
| if limit, err := strconv.Atoi(limitStr); err == nil { | |
| maxLimit = limit | |
| const maxAllowedLimit = 1000 | |
| if limitStr := c.Query("max_limit"); limitStr != "" { | |
| if limit, err := strconv.Atoi(limitStr); err == nil { | |
| if limit > 0 { | |
| if limit > maxAllowedLimit { | |
| maxLimit = maxAllowedLimit | |
| } else { | |
| maxLimit = limit | |
| } | |
| } |
c545b01 to
d3ff8d7
Compare
Fixes #15
Added a new API endpoint
/lost_found/allthat returns both lost and found items in a single response, sorted based on creation time. It has an optional query parametermax_limitthat controls the numbers of items returned.