-
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
Solution #139
base: master
Are you sure you want to change the base?
Solution #139
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.
Thank you for your hard work on this project! 😊 While your server implementation is solid and meets many of the task requirements, there are a few critical issues that need to be addressed before we can approve the pull request. The most important issue is the missing HTML form implementation, which is a core requirement of the task. Additionally, there are potential runtime errors related to the handling of compressionType
and file
from the form data. Please ensure these elements are correctly accessed and validated to prevent errors. Once these issues are resolved, your solution will be much stronger. Keep up the great work, and I'm confident you'll nail it with the next iteration! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review
button in the Reviewers tab.
src/createServer.js
Outdated
deflate: zlib.createDeflate, | ||
}; | ||
|
||
form.parse(req, (err, { compressionType }, { file }) => { |
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 destructuring of compressionType
and file
from the parsed form data might not work as expected if the form fields are not named exactly as assumed. Ensure that the form fields are correctly named and that compressionType
and file
are accessed correctly.
src/createServer.js
Outdated
}; | ||
|
||
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 condition !file || !compressionType
might not be sufficient if file
or compressionType
are arrays or objects. Consider checking if file[0]
and compressionType[0]
exist and are valid.
|
||
return; | ||
} | ||
|
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.
Ensure that file[0]
is a valid object with the expected properties. If file
is not an array, this line will cause an error.
src/createServer.js
Outdated
} | ||
|
||
const uploadFile = file[0]; | ||
const gzipStream = compressors[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[0]
is used directly. Ensure that compressionType
is an array and has at least one element to avoid runtime errors.
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.
Review Summary
Great effort on implementing the server functionality! 🎉 Your code is mostly on the right track, but there are a few critical issues that need attention:
-
Missing HTML Form Implementation: The task requires an HTML form for users to select a file, choose a compression type, and submit it to the server. This is a core requirement and currently missing. Adding this form will complete the user interaction part of your project.
-
Handling of
compressionType
andfile
: Your server code increateServer.js
does a good job of validating thecompressionType
andfile
. However, ensure that you handle cases where these are missing or invalid to prevent runtime errors. -
Response Headers: Consider adding a
Content-Type
header to the response to ensure that the client handles the file download correctly. You can set it usingres.setHeader('Content-Type', 'application/octet-stream');
. -
Server Implementation: The server correctly handles streams and uses the
zlib
module for file compression. It also responds with appropriate status codes for various scenarios, which is well done.
The decision to approve is made to help you move forward with your learning. Please review the comments and address the critical issues, especially the missing HTML form, to enhance your solution. Keep up the good work and continue improving your code! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
res.writeHead(200, { | ||
'content-disposition': `attachment; filename=${file.originalFilename}.${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.
Consider adding a Content-Type
header to the response to ensure that the client handles the file download correctly. This can be done by setting res.setHeader('Content-Type', 'application/octet-stream');
.
No description provided.