Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add solution #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

andriy-kostiuk
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.

Great job on implementing the HTTP server! 🎉 The code is well-structured and meets the task requirements. While there are a few minor issues, such as the need for better validation of the 'compressionType' and 'file' fields, and the use of a 405 status code for GET requests on the 'compress' route, these do not significantly impact the functionality. Keep up the good work and consider these improvements for future projects! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

Comment on lines +19 to +20
res.writeHead(400, { 'content-type': 'text/plain' });
res.end('Request should be POST method!');

Choose a reason for hiding this comment

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

When the request method is GET for the 'compress' route, it would be more appropriate to return a 405 Method Not Allowed status code instead of 400 Bad Request. This status code better indicates that the method is not allowed for the requested resource.

};

form.parse(req, (err, { compressionType }, { file }) => {
if (err || !file || !compressionType) {

Choose a reason for hiding this comment

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

The 'compressionType' and 'file' fields are assumed to be arrays. Ensure that these fields are validated properly to avoid potential runtime errors. Consider checking if 'compressionType' and 'file' are arrays and have at least one element before accessing them.

return;
}

if (!compressors.hasOwnProperty(compressionType[0])) {

Choose a reason for hiding this comment

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

The 'compressionType' field is assumed to be an array. Ensure that it is validated properly before accessing its first element. Consider adding a check to confirm that 'compressionType' is an array and has at least one element.

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