Skip to content

Implement case transformer server - #1184

Open
droopy-bit wants to merge 2 commits into
mate-academy:masterfrom
droopy-bit:develop
Open

Implement case transformer server#1184
droopy-bit wants to merge 2 commits into
mate-academy:masterfrom
droopy-bit:develop

Conversation

@droopy-bit

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 approving your solution. The server correctly parses query parameters, validates text and toCase, aggregates multiple errors, invokes convertToCase, and returns the expected JSON structure and error messages. One minor improvement: on line 28 you validate with toCase.toUpperCase(), but on line 46 you pass the original toCase to convertToCase. If convertToCase expects uppercase values (matching supportedCases), this could lead to inconsistent behavior. Consider passing toCase.toUpperCase() to convertToCase or normalizing input inside convertToCase for consistency. Overall, functionality appears intact and requirements are met—nice work.


✨ 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
Comment on lines +28 to +46

if (toCase !== null && !supportedCases.includes(toCase.toUpperCase())) {
errors.push({
message:
'This case is not supported. Available cases: SNAKE, KEBAB, ' +
'CAMEL, PASCAL, UPPER.',
});
}

if (errors.length > 0) {
res.setHeader('Content-Type', 'application/json');
res.statusCode = 400;
res.statusMessage = 'Bad request';
res.end(JSON.stringify({ errors }));

return;
}

const result = convertToCase(text, toCase);

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 validation converts toCase to uppercase for checking (toCase.toUpperCase()), but line 46 passes the original toCase value to convertToCase. If the business logic expects uppercase values (as the supportedCases array suggests), this inconsistency could cause issues. Consider passing toCase.toUpperCase() to convertToCase for consistency.

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