Skip to content

add solution#1101

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

add solution#1101
6ORSH wants to merge 5 commits intomate-academy:masterfrom
6ORSH:develop

Conversation

@6ORSH
Copy link
Copy Markdown

@6ORSH 6ORSH commented Apr 1, 2026

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

Great job setting up the basic server structure and correctly setting the Content-Type header. However, some changes are needed before this can be approved. The main issue is that the server always responds with a 200 OK status code. According to the requirements, when a request is invalid, the server must respond with a 400 Bad Request status. Currently, the status code in src/createServer.js is hardcoded. You'll need to update this to set the response.statusCode dynamically based on whether the request validation passes or fails.


✨ 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 thread src/createServer.js Outdated
function createServer() {
const server = http.createServer((request, response) => {
response.setHeader('Content-Type', 'application/json');
response.statusCode = 200;
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 response status code is hardcoded to 200. According to the requirements, if the request is invalid, the server should respond with a 400 status code and 'Bad request' status text. The status code should be set dynamically after getResponseData is called, based on whether the request was valid.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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

Great job refactoring the response logic into the getResponseData function! That's a nice improvement to the code's structure. However, this submission requires changes because the main issue from the last review hasn't been addressed: the server still sends a 200 OK status for all requests, including invalid ones that should trigger a 400 Bad Request.

To fix this, you need to dynamically set the status code in src/createServer.js based on the validation result before sending the response:

  • If responseData contains an errors property, set response.statusCode = 400 and response.statusMessage = 'Bad request'.
  • If there are no errors, set response.statusCode = 200 and response.statusMessage = 'OK'.

Once you've implemented this, your server will be fully compliant with the requirements.


✨ 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 thread src/createServer.js
Comment on lines +17 to +19
response.write(JSON.stringify(responseData));
response.statusCode = 200;
response.end();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This section needs an update to meet the requirements. The status code is still hardcoded to 200, which was the main issue from the previous review.

According to the task description, you need to:

  1. Check if responseData contains an error.
  2. If it does, set response.statusCode to 400 and response.statusMessage to 'Bad request'.
  3. If it's a successful response, set response.statusCode to 200 and response.statusMessage to 'OK'.

Also, it's important to set these properties on the response object before you send the body with response.write() or response.end().

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

I am approving this solution so you can move forward, but please take a moment to review the feedback for your next project.

Excellent work fixing the status code handling from the last review! The server is very close to meeting all requirements. There are just two small areas for improvement:

  1. In src/createServer.js, the response for non-GET requests (the 'Not Found' case) sends plain text. A requirement is that the server must always respond with JSON. This should be changed to send a JSON object, like JSON.stringify({ message: 'Not Found' }).
  2. In src/getResponseData.js, business logic like detectCase() is called before all validation is finished. It's best practice to perform all validation first. Only after confirming there are no errors should you call functions like detectCase and convertToCase.

These changes will make your code more robust and fully compliant. You've done a great job on this task!


✨ 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 Outdated

if (request.method !== 'GET') {
response.statusCode = 404;
response.end('Not Found');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

According to the "General rules" in the requirements, the server must always respond with a JSON type. This response sends a plain string instead of a JSON object. To be compliant, this should also be a JSON response, for example: JSON.stringify({ message: 'Not Found' }).

Comment thread src/getResponseData.js Outdated
errors.push({ message: MISSING_TEXT_ERROR });
}

const originalCase = detectCase(originalText);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This call to detectCase happens before you've finished all the validation checks. For example, if originalText is empty, an error is added to the errors array, but this function is still executed with an empty string.

It's better practice to perform all validation first (checking originalText and targetCase). Only after confirming there are no errors should you proceed to call any business logic functions like detectCase and convertToCase.

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