Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great work on implementing the server-side logic to save the expense data—that part is functioning correctly. However, a couple of critical requirements are missing, so this submission needs changes before it can be approved.
First, the application must serve an HTML form to the user. You need to add a handler for a GET request (for example, at the root path /) that reads the public/index.html file and sends it as the response.
Second, after a successful POST to /add-expense, the server's response must be an HTML page, not raw JSON. Please change the Content-Type header to text/html and embed the saved JSON data within the HTML body, for instance, inside <pre> tags to preserve formatting.
✨ 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
| // Return instance of http.Server class | ||
| const server = new http.Server(); | ||
|
|
||
| server.on('request', (req, res) => { |
There was a problem hiding this comment.
According to the task description, the application should show an HTML form. The server is currently only handling POST requests to /add-expense. You need to add a handler for a GET request to serve the form to the user.
| res.setHeader('Content-Type', 'application/json'); | ||
|
|
||
| return res.end(JSON.stringify(data)); |
There was a problem hiding this comment.
The task requires returning an HTML page with the saved data. Your response has a Content-Type of application/json. It should be text/html, and the JSON data should be part of the HTML body, for example, inside <pre> tags to preserve formatting.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work on updating the server! It now correctly serves an HTML form and responds with an HTML page after a POST request, which perfectly aligns with the requirements. The only remaining issue is that the tests are now out of sync with this new functionality, causing them to fail. The test suite in tests/formDataServer.test.js still expects a Content-Type of application/json for the POST request, but your server correctly sends text/html. Please update the test to assert the correct content type and to check for the response data within an HTML body (e.g., inside <pre> tags). Once the tests match the server's correct behavior, we'll be ready to approve this.
✨ 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
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am approving this submission as an educational override to help you progress, but there's a key requirement that needs to be addressed. You've done a great job implementing the form and saving the data correctly! However, the server is currently returning a raw JSON response instead of an HTML page.
The task requires the server to return an HTML page that contains the well-formatted JSON. To fix this, please update src/createServer.js to set the Content-Type header to text/html and wrap the JSON data in HTML tags (e.g., <pre>). Afterward, you'll also need to update your tests to assert that the response is text/html and that the body contains the expected data within the HTML structure. Keep up the excellent effort!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| fs.writeFileSync(dbPath, JSON.stringify(data)); | ||
|
|
||
| res.statusCode = 200; | ||
| res.setHeader('Content-Type', 'application/json'); |
There was a problem hiding this comment.
The task requires the server to "return an HTML page with well formatted JSON". To do that, the Content-Type header should be set to text/html.
| res.statusCode = 200; | ||
| res.setHeader('Content-Type', 'application/json'); | ||
|
|
||
| return res.end(JSON.stringify(data)); |
There was a problem hiding this comment.
This sends back a raw JSON response. Per the requirements, you should send back an HTML document that contains the formatted JSON data. For example, you could wrap the JSON string in <pre> tags within a basic HTML structure.
No description provided.