solution - #1151
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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, missingtoCase, or unsupported case), set bothres.statusCode = 400andres.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 = 200andres.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
| if (errors.length) { | ||
| res.statusCode = 400; |
There was a problem hiding this comment.
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.
| const { originalCase, convertedText } = convertToCase(text, toCase); | ||
|
|
||
| res.end( |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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! ✨
No description provided.