Skip to content

add task solution#940

Open
KrawczykDamiann wants to merge 1 commit into
mate-academy:masterfrom
KrawczykDamiann:develop
Open

add task solution#940
KrawczykDamiann wants to merge 1 commit into
mate-academy:masterfrom
KrawczykDamiann:develop

Conversation

@KrawczykDamiann
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Your implementation successfully meets all stated requirements. The expense tracking app correctly implements two collections (users and expenses) with five endpoints each, uses Express.js as specified, maintains in-memory storage that persists during runtime, and returns appropriate HTTP status codes (404 for missing entities, 400 for missing required parameters). The exported createServer() function returns the Express app without calling app.listen(), which is the expected pattern for testing.

Regarding the file comment about adding userId validation to the PATCH endpoint for consistency - while this would indeed be a good practice, it's not a critical blocker since the task requirements don't explicitly mandate this validation. Your implementation satisfies all explicit requirements, and the code is well-structured.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Comment thread src/createServer.js
Comment on lines +177 to +189

app.patch('/expenses/:id', (req, res) => {
const id = Number(req.params.id);
const expense = expenses.find((e) => e.id === id);

if (!expense) {
return res.status(404).send('Not found');
}

const { userId, spentAt, title, amount, category, note } = req.body || {};

if (userId !== undefined) {
expense.userId = userId;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The PATCH /expenses/:id endpoint allows updating userId to a non-existent user without validation. While the task requirements don't explicitly mandate this, the POST /expenses endpoint validates userId exists - consider adding the same validation here for consistency when userId is being updated.

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.

2 participants