Skip to content

solution - #1151

Open
Nika-Andriy wants to merge 3 commits into
mate-academy:masterfrom
Nika-Andriy:develop
Open

solution#1151
Nika-Andriy wants to merge 3 commits into
mate-academy:masterfrom
Nika-Andriy:develop

Conversation

@Nika-Andriy

Copy link
Copy Markdown

No description provided.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

I am requesting changes because one explicit requirement from the checklist is still not met and it directly affects the HTTP behavior. Your server currently sets res.statusCode = 400 for invalid input but does not set res.statusMessage = 'Bad request', and on the success path it relies on the default status instead of explicitly setting res.statusCode = 200 and res.statusMessage = 'OK'. This violates the requirement that both success and error responses must have specific status codes and status texts, so it is considered a critical blocker for this task.

Critical issues to fix:

  • In src/createServer.js, in the error branch (where you detect missing text, missing toCase, or unsupported case), set both res.statusCode = 400 and res.statusMessage = 'Bad request' before writing the JSON error body and ending the response [CHECKLIST ITEM #14].
  • In the success branch (after validation passes and before sending the converted result), set res.statusCode = 200 and res.statusMessage = 'OK' before writing the JSON response [CHECKLIST ITEM #9].

Once you add these explicit status settings, your implementation will align fully with the task requirements. Everything else—including URL parsing, validations, use of convertToCase, and JSON response shapes—is implemented well, so you’re very close to completion. Keep those small adjustments in mind as a pattern whenever a specification calls out specific HTTP status codes and status texts.


✨ 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 +57 to +58
if (errors.length) {
res.statusCode = 400;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When returning an error response you set statusCode = 400, but the task also requires setting the status text to "Bad request"; consider setting res.statusMessage = 'Bad request' here before ending the response.

Comment thread src/createServer.js
Comment on lines +64 to +66
const { originalCase, convertedText } = convertToCase(text, toCase);

res.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.

Before sending the successful response body, set res.statusCode = 200 and res.statusMessage = 'OK' to explicitly match the requirement for a 200 OK response.

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

Copy link
Copy Markdown

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 your solution because it fully meets the functional and behavioral requirements of the case transformer server. Your createServer correctly uses Node's http module, returns the created server, and cleanly delegates the transformation logic to the provided convertToCase(text, toCase) function. The URL parsing logic (/<TEXT_TO_CONVERT>?toCase=<CASE_NAME>) and query handling with URLSearchParams are implemented as specified, including treating the leading slash-stripped segment as the required text. All validation rules are covered: you detect missing text, missing toCase, and unsupported case names, and you return the exact required error messages in an errors array with status 400 and status message Bad request. On success, you set status 200 with status message OK, always send JSON with Content-Type: application/json, and respond with the correct shape: originalCase, targetCase, originalText, and convertedText. Overall, the server behaves as required for both valid and invalid inputs, and there are no remaining critical or blocking issues. Nicely done getting all the edge cases and HTTP details aligned with the specification.


✨ 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