Skip to content

Solution#1111

Open
PolianskyiDmytro wants to merge 1 commit into
mate-academy:masterfrom
PolianskyiDmytro:develop
Open

Solution#1111
PolianskyiDmytro wants to merge 1 commit into
mate-academy:masterfrom
PolianskyiDmytro:develop

Conversation

@PolianskyiDmytro
Copy link
Copy Markdown

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

Your solution is approved because it correctly implements the required HTTP server behavior and satisfies the core functional specifications. The server exports createServer, uses Node's http module, always responds with JSON, validates both text and toCase with the exact required error messages, and calls convertToCase(text, toCase) to produce the expected success payload. One minor improvement would be to explicitly set res.statusMessage = 'OK' alongside res.statusCode = 200 in the success path (around line 52) so the status text is guaranteed to match the requirement, even if the default changes. Another small robustness improvement would be to avoid relying on req.headers.host when parsing the URL (currently done with new URL(req.url, http://${req.headers.host})) near line 14) and instead split req.url on ? and use new URLSearchParams(queryString) as hinted in the task. These are not blockers for functionality, but addressing them would make your implementation more explicit and resilient. Overall, well done on meeting the task requirements and handling validation and response formatting carefully.


✨ 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
result.originalText = text;
result.targetCase = toCase;

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

Per requirements the server should respond with status 200 and status text "OK". You set res.statusCode = 200 (line 52) but do not explicitly set res.statusMessage = 'OK'. Node defaults to "OK" for 200, but tests/requirements expect the status text; consider adding res.statusMessage = 'OK' before sending the response to be explicit.

Comment thread src/createServer.js
res.setHeader('Content-Type', 'application/json');

const cases = ['SNAKE', 'KEBAB', 'CAMEL', 'PASCAL', 'UPPER'];
const url = new URL(req.url, `http://${req.headers.host}`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You parse the request using new URL(req.url, http://${req.headers.host}) (line 14). This works in most cases, but it relies on req.headers.host being present. The task hint suggests splitting req.url by ? and using URLSearchParams on the query string — that approach avoids depending on the host header and is slightly more robust for this specific task environment. Consider extracting the query string by splitting req.url and using new URLSearchParams(queryString) to match the hint exactly.

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