Skip to content

feat: set up repo structure and backend connection#1

Merged
jordan-smith721 merged 3 commits intomongodb:mainfrom
jordan-smith721:DOCSP-54407-initialize-backend
Oct 13, 2025
Merged

feat: set up repo structure and backend connection#1
jordan-smith721 merged 3 commits intomongodb:mainfrom
jordan-smith721:DOCSP-54407-initialize-backend

Conversation

@jordan-smith721
Copy link
Copy Markdown
Collaborator

Adds initial repo structure and establishes a connection to MongoDB. Uses a basic get endpoint to test functionality.

@jordan-smith721 jordan-smith721 changed the title Set up repo structure and backend connection feat: set up repo structure and backend connection Oct 7, 2025
@jordan-smith721 jordan-smith721 marked this pull request as ready for review October 7, 2025 15:07
Comment thread server/express/src/utils/errorHandler.ts Outdated
Comment thread server/express/src/types/index.ts Outdated
Comment thread server/express/src/types/index.ts Outdated
Comment thread server/express/src/controllers/movieController.ts
Comment thread server/express/package.json Outdated
Comment thread server/express/src/config/database.ts Outdated
Comment thread server/express/src/utils/errorHandler.ts
Comment thread server/express/src/utils/errorHandler.ts Outdated
Comment thread server/express/src/utils/errorHandler.ts
Comment thread server/express/src/config/database.ts Outdated
res.json(createSuccessResponse(movies, `Found ${movies.length} movies`));

} catch (error) {
throw new Error(`Failed to retrieve movies: ${error instanceof Error ? error.message : 'Unknown error'}`);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new Error(`Failed to retrieve movies: ${error instanceof Error ? error.message : 'Unknown error'}`);
throw error;

why not pass the actual MDB error?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - simplified

Comment thread server/express/package.json Outdated
@@ -0,0 +1,29 @@
{
"name": "Sample Mflix Express.js Backend",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"name": "Sample Mflix Express.js Backend",
"name": "sample-mflix-express.js-backend",

I thought the convention was kebab-case

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

Comment thread server/express/src/app.ts

// Load environment variables from .env file
// This must be called before any other imports that use environment variables
dotenv.config();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want any validation for required vars?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread server/express/src/app.ts
}

/**
* Graceful Shutdown Handler
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to close the connection before exiting?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bad idea - added a call to closeDatabaseConnection()


try {
// Create new MongoDB client instance
client = new MongoClient(uri);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there any recommended cxn options that we want to show?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread server/express/src/app.ts
*/
async function startServer() {
try {
console.log('Starting MongoDB Sample MFlix API...');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment thread server/express/src/config/database.ts Outdated
Comment on lines +45 to +47
throw new Error(
`Database connection failed: ${error instanceof Error ? error.message : 'Unknown error'}`
);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Copy Markdown

@baileympearson baileympearson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why, but I can't resolve my comments on the PR. Anything I've given 👍 on is good to resolve.

@jordan-smith721 jordan-smith721 merged commit 8234ec7 into mongodb:main Oct 13, 2025
cbullinger added a commit that referenced this pull request Jan 31, 2026
- #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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants