Skip to content

Conversation

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

I am requesting changes because there are critical issues that violate the required implementation details and will cause tests to fail. Specifically:

  • In src/createServer.js, the URL parsing must follow the spec: split req.url by ? into path and queryString, extract text from path (remove leading /), and use const params = new URLSearchParams(queryString || '') with params.get('toCase'). Using the URL constructor and url.searchParams does not meet the requirement.
  • The call to convertToCase uses the wrong argument order. Per the spec, it should be convertToCase(caseName, text), so update the call to convertToCase(toCase, text) to avoid incorrect outputs.
  • When returning validation errors, you must set both status code and status text exactly: res.writeHead(400, 'Bad request', { 'Content-Type': 'application/json' }). Similarly, for success responses, explicitly set res.writeHead(200, 'OK', { 'Content-Type': 'application/json' }).

Everything else (error messages, response JSON shape, headers, export) looks good. Fixing the above will align the server with the checklist and allow the tests to pass. Keep up the good work—these are straightforward adjustments to make.


✨ 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


function createServer() {
return http.createServer((req, res) => {
const url = new URL(req.url, `http://${req.headers.host}`);

Choose a reason for hiding this comment

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

The task requires splitting req.url by ? and using new URLSearchParams(queryString) to read the toCase value. This line uses the WHATWG URL constructor and url.searchParams instead of the exact required parsing approach. Update the code to: - split req.url by ? into path and queryString - extract text from the path (remove leading /) - create const params = new URLSearchParams(queryString || '') and use params.get('toCase') as required by the Implementation Details / Validation flow.

}

try {
const { originalCase, convertedText } = convertToCase(text, toCase);

Choose a reason for hiding this comment

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

You call convertToCase(text, toCase) here, but the specification requires convertToCase(caseName, text) (first argument = case name, second = text). This reversed order will produce incorrect results or runtime errors. Call convertToCase(toCase, text) so the function receives caseName first as required.

}

if (errors.length > 0) {
res.writeHead(400, { 'Content-Type': 'application/json' });

Choose a reason for hiding this comment

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

When returning validation errors you must set HTTP status code and status text to exactly 400 and "Bad request" (the Implementation Details require the status text). Use the writeHead overload that accepts a status message, for example: res.writeHead(400, 'Bad request', { 'Content-Type': 'application/json' }). Currently the code only supplies headers, which will use Node's default status message (not the exact required text).

convertedText,
};

res.writeHead(200, { 'Content-Type': 'application/json' });

Choose a reason for hiding this comment

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

The requirements state the server must set the status text for successful responses to "OK". While Node's default for 200 is OK, to strictly follow the spec make the status text explicit by calling res.writeHead(200, 'OK', { 'Content-Type': 'application/json' }) before sending the success response.

Copy link

@Anton-Kuchmasov Anton-Kuchmasov left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

3 participants