created API for restaurants - #2
Merged
Merged
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds restaurant and booking Mongoose models, four restaurant read handlers, Express routes for listings, featured restaurants, slug lookup, and date-filtered bookings, and mounts them under ChangesRestaurant API
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant restaurantRouter
participant restaurantController
participant MongoDB
Client->>restaurantRouter: GET /api/restaurants endpoint
restaurantRouter->>restaurantController: Invoke matched handler
restaurantController->>MongoDB: Query restaurants or bookings
MongoDB-->>restaurantController: Return matching documents
restaurantController-->>Client: Return JSON response
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@server/controllers/restaurantController.ts`:
- Around line 49-50: Update the Restaurant.find query in the listing flow and
the corresponding slug endpoint populate calls to exclude the owner email,
returning only explicitly public owner fields such as name. Keep the owner
relationship populated while removing email from both public restaurant read
responses.
- Around line 27-31: Update the search handling in the restaurant query
construction to escape all regex metacharacters in the user-provided search
value and truncate or reject inputs exceeding a short maximum length before
assigning query.name.$regex. Preserve case-insensitive matching while ensuring
the resulting MongoDB regex is bounded and safe.
- Around line 46-53: Validate the page and limit inputs before the
Restaurant.find pagination chain: require finite positive integers, apply a
reasonable maximum cap to limit, and use safe fallback values for invalid
inputs. Pass only the validated page and capped limit to skip() and limit().
- Around line 155-180: Update the date handling before the Booking.find query to
require an exact YYYY-MM-DD value and reject malformed or calendar-invalid dates
with the existing 400 response. Construct the day range in UTC, using UTC
midnight as the inclusive start and the following UTC midnight as an exclusive
upper bound; update the bookingDate filter accordingly.
In `@server/models/Booking.ts`:
- Around line 10-12: Rename the misspelled cccasion property to occasion in the
Booking model and add the corresponding occasion field to BookingSchema,
preserving its optional string type so values accepted by TypeScript are
retained by Mongoose.
In `@server/routes/restaurant.routes.ts`:
- Around line 17-18: Update the getRestaurantBookings route and its handler to
require restaurant-owner or admin authorization before returning booking
records; alternatively, restrict the response to non-identifying slot
availability and omit reservation status and populated customer names or emails.
Ensure arbitrary restaurant IDs cannot expose protected booking data.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6ba18423-684e-486f-a03a-6d8f7ea0b5e7
📒 Files selected for processing (5)
server/controllers/restaurantController.tsserver/models/Booking.tsserver/models/Restaurants.tsserver/routes/restaurant.routes.tsserver/server.ts
This was referenced Jul 18, 2026
Merged
Merged
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.
Summary by CodeRabbit
/api/restaurants.