feat: set up repo structure and backend connection#1
Conversation
| res.json(createSuccessResponse(movies, `Found ${movies.length} movies`)); | ||
|
|
||
| } catch (error) { | ||
| throw new Error(`Failed to retrieve movies: ${error instanceof Error ? error.message : 'Unknown error'}`); |
There was a problem hiding this comment.
| throw new Error(`Failed to retrieve movies: ${error instanceof Error ? error.message : 'Unknown error'}`); | |
| throw error; |
why not pass the actual MDB error?
There was a problem hiding this comment.
Good question - simplified
| @@ -0,0 +1,29 @@ | |||
| { | |||
| "name": "Sample Mflix Express.js Backend", | |||
There was a problem hiding this comment.
| "name": "Sample Mflix Express.js Backend", | |
| "name": "sample-mflix-express.js-backend", |
I thought the convention was kebab-case
There was a problem hiding this comment.
Good catch
|
|
||
| // Load environment variables from .env file | ||
| // This must be called before any other imports that use environment variables | ||
| dotenv.config(); |
There was a problem hiding this comment.
do we want any validation for required vars?
There was a problem hiding this comment.
There's a ticket to verify requirements later in the epic where we can implement this (and anything else that comes up between now and then): https://jira.mongodb.org/browse/DOCSP-54423
| } | ||
|
|
||
| /** | ||
| * Graceful Shutdown Handler |
There was a problem hiding this comment.
do we want to close the connection before exiting?
There was a problem hiding this comment.
Not a bad idea - added a call to closeDatabaseConnection()
|
|
||
| try { | ||
| // Create new MongoDB client instance | ||
| client = new MongoClient(uri); |
There was a problem hiding this comment.
are there any recommended cxn options that we want to show?
There was a problem hiding this comment.
Definitely open to adding some if we think its worthwhile - my assumption was that those would be handled via the connection string if they wanted to use any
| */ | ||
| async function startServer() { | ||
| try { | ||
| console.log('Starting MongoDB Sample MFlix API...'); |
There was a problem hiding this comment.
maybe mention in a comment or in the README that you'd probably want to use a logging library in a production app? (vs. console.log and console.error)
There was a problem hiding this comment.
I think this is something we can add to the README once we create that (there's a separate ticket for it for after development)
| const moviesCollection = getCollection('movies'); | ||
|
|
||
| try { | ||
| // Execute the find operation with all options |
There was a problem hiding this comment.
do we want to mention .project(some fields) in a comment or in another example to demonstrate projection / improving performance to only return fields we need?
There was a problem hiding this comment.
This is just a placeholder endpoint for now. I'm working on creating the CRUD endpoints now that adds actual logic - I don't have projection in there but it's probably a good idea to add it!
| throw new Error( | ||
| `Database connection failed: ${error instanceof Error ? error.message : 'Unknown error'}` | ||
| ); |
There was a problem hiding this comment.
| throw new Error( | |
| `Database connection failed: ${error instanceof Error ? error.message : 'Unknown error'}` | |
| ); | |
| throw error; |
why are we wrapping instead of letting the MongoError surface?
baileympearson
left a comment
There was a problem hiding this comment.
I'm not sure why, but I can't resolve my comments on the PR. Anything I've given 👍 on is good to resolve.
- #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.
Adds initial repo structure and establishes a connection to MongoDB. Uses a basic get endpoint to test functionality.