feat: implement CRUD API w/ testing#2
Conversation
cbullinger
left a comment
There was a problem hiding this comment.
A couple questions and suggestions
| // Parse and validate pagination parms for invalid inputs | ||
| const limitNum = Math.min( | ||
| Math.max( | ||
| parseInt(limit) || 20, // Default to 20 if invalid | ||
| 1 // Min 1 result | ||
| ), | ||
| 100 // Cap at 100 results for performance | ||
| ); | ||
| const skipNum = Math.max( | ||
| parseInt(skip) || 0, // Default to 0 if invalid | ||
| 0 // skip must be positive number | ||
| ); |
There was a problem hiding this comment.
minor comment - indentation is strange here. should we add a formatter to the project?
There was a problem hiding this comment.
Yeah good call. Formatted all files w/ Prettier
|
|
||
| // Prepare the document for insertion | ||
| // Here you can add metadata or other fields that might be necessary | ||
| const movieDocument: Partial<Movie> = { |
There was a problem hiding this comment.
Is there a reason to clone movieData?
There was a problem hiding this comment.
The idea was just in case someone wanted to add metadata or something if they edit this app, but thinking about that now that seems like overkill for this so I removed it
| // Retrieve the created document to return complete data | ||
| const createdMovie = await moviesCollection.findOne({ _id: result.insertedId }); | ||
|
|
There was a problem hiding this comment.
Why is this necessary? Can't you just return movieData?
There was a problem hiding this comment.
I did it this way so that it retrieves the actual full document that got inserted, rather than returning what the user submits. At the end of the day it'll likely be the same info, but this seemed like a better way to show that the document was actually inserted.
Happy to edit it if you feel strongly, I'm not tied to doing either way
- #1 Movie Cards: Make entire card clickable, enforce consistent heights, tone down checkbox - #2 Top Toolbar: Remove batch buttons, add contextual bottom selection bar - #3 Filters Bar: Replace mint/green with neutral gray borders and backgrounds - #4 Navbar: Remove full-width green border and animated underline effect - #5 Aggregations: Use light gray for row hover, tone down comment pills and show more button - Additional: Remove bright green border from aggregations section headers All changes improve visual hierarchy and reduce competing visual elements per reviewer feedback on PR #75.
Implements API endpoints for CRUD operations w/ unit testing