-
Notifications
You must be signed in to change notification settings - Fork 200
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
base: master
Are you sure you want to change the base?
add solution #130
Conversation
There was a problem hiding this 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! ✨
res.writeHead(400, { 'content-type': 'text/plain' }); | ||
res.end('Request should be POST method!'); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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])) { |
There was a problem hiding this comment.
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.
No description provided.