Skip to content

add solution of task node_form-data#160

Open
Voloshynd wants to merge 6 commits intomate-academy:masterfrom
Voloshynd:develop
Open

add solution of task node_form-data#160
Voloshynd wants to merge 6 commits intomate-academy:masterfrom
Voloshynd:develop

Conversation

@Voloshynd
Copy link

No description provided.

Copy link

@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

Thanks for your work! However, there's a critical issue: your code currently overwrites the entire db/expense.json file with only the latest expense, erasing all previous entries. To meet the requirements, you need to read the existing array of expenses, append the new one, and then write the updated array back to the file. Please fix this logic so that all expenses are preserved. You're almost there—keep going! 🚀


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

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines 52 to 65
const writeStream = fs.createWriteStream(filePath);

writeStream.on('error', (err) => {
// eslint-disable-next-line no-console
console.error('Write error:', err.message);
});

writeStream.on('finish', () => {
// eslint-disable-next-line no-console
console.log('Expense data written successfully.');
});

writeStream.write(jsonString);
writeStream.end();

Choose a reason for hiding this comment

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

Issue: The code creates a write stream and writes only the new expense object to the file, overwriting the entire file. This will erase all previous expenses and only keep the latest one. You should read the existing expenses, append the new one, and then write the updated array back to the file. This is a critical logic error.

Copy link

@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

Great job! 🎉 Your implementation meets all the core requirements: the server serves the HTML form, handles POST requests, appends new expenses without overwriting previous ones, and returns a well-formatted HTML response. All previous issues have been resolved, and your solution is complete and correct. Keep up the excellent work!


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

Footnotes

  1. Rate AI review example

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