Skip to content

solution#1070

Open
artemstadnik wants to merge 3 commits intomate-academy:masterfrom
artemstadnik:demo
Open

solution#1070
artemstadnik wants to merge 3 commits intomate-academy:masterfrom
artemstadnik:demo

Conversation

@artemstadnik
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

Great job on implementing the server and handling the core logic! I am requesting a couple of changes to make your solution more robust and fully compliant with the requirements.

First, there's a critical issue that can crash the server. If a request is made without a query string (e.g., /some-text), your URL parsing logic at src/createServer.js will cause a TypeError because urlParams[1] will be undefined. Please add a check or a default value to handle this case gracefully.

Additionally, the task requires the success status message to be OK, but your code currently sends ok. Please update this to match the specification.

Once you've fixed these points, your server will be solid!


✨ 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

return http.createServer((req, res) => {
const urlParams = req.url.split('?');
const text = urlParams[0].slice(1);
const queryString = urlParams[1];

Choose a reason for hiding this comment

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

This line might lead to a server crash. If the request URL doesn't have a query string (no ?), urlParams[1] will be undefined. Passing this to URLSearchParams on line 10 will throw a TypeError. How could you provide a default value for queryString to prevent this?

if (errors.length > 0) {
res.statusCode = 400;
res.statusMessage = 'Bad request';
res.setHeader('Content-type', 'application/json');

Choose a reason for hiding this comment

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

While HTTP headers are case-insensitive, it's a good practice to be consistent with their casing. Here you've used Content-type, but on line 54 you used Content-Type. Sticking to the standard Content-Type is recommended.

const result = convertToCase(text, toCase);

res.statusCode = 200;
res.statusMessage = 'ok';

Choose a reason for hiding this comment

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

The task requirements specify that the success status text should be OK, not ok.

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

Excellent work on this iteration! I am approving your solution as you've successfully addressed all the feedback from the previous review. The server now correctly handles requests without query strings, and the status messages are fully compliant with the requirements. Your code is clean, robust, and meets all the task specifications. Great job!


✨ 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