Skip to content

Solution#197

Open
oberezhnay wants to merge 4 commits intomate-academy:masterfrom
oberezhnay:develop
Open

Solution#197
oberezhnay wants to merge 4 commits intomate-academy:masterfrom
oberezhnay:develop

Conversation

@oberezhnay
Copy link

Compression App

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.

Review Summary

Great work on setting up the server and using streams with the zlib module. However, this requires changes because a few critical issues are preventing the application from functioning correctly.

Here are the main points to address:

  • Broken HTML Form: In src/index.html, the form is created with a <br> tag instead of a <form> tag. This is a critical issue that prevents the form from submitting any data.
  • Incorrect File Extensions: In src/createServer.js, the output file extensions don't match the requirements. They should be .gz for gzip and .dfl for deflate.
  • Hanging Request: When a POST request is made to /compress with an invalid content-type, your server sets the status code to 400 but never sends a response. This causes the client's request to hang and eventually time out.

Please address these points, and I'll be happy to take another look!


✨ 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

src/index.html Outdated
<title>Document</title>
</head>
<body>
<br action="/compress" method="POST" enctype="multipart/form-data">

Choose a reason for hiding this comment

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

This should be a <form> tag, not a <br> tag. An HTML form must start with <form> to be able to submit data.

src/index.html Outdated
<body>
<br action="/compress" method="POST" enctype="multipart/form-data">
<label for="file">Select file: </label>
<input type="file" id="file" name="file" require>

Choose a reason for hiding this comment

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

There's a typo in the attribute here. To make this input field mandatory, the attribute should be required instead of require.

src/index.html Outdated
<label for="file">Select file: </label>
<input type="file" id="file" name="file" require>

<label for="compressionType">Choose comresion type: </label>

Choose a reason for hiding this comment

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

There's a typo in the label text. It should be 'compression'.

<br />

<button type="submit">Compress</button>
</form>

Choose a reason for hiding this comment

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

This closing </form> tag does not have a matching opening <form> tag. This is because a <br> tag was used on line 9 instead.

Comment on lines 46 to 49
if (!contentType || !contentType.includes('multipart/form-data')) {
res.statusCode = 400;

return;

Choose a reason for hiding this comment

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

When the content-type is invalid, you set the status code but never send a response back to the client. This will cause the request to hang. Consider using your sendStatus helper function here to ensure a response is sent.


if (compressionType === 'gzip') {
compressor = zlib.createGzip();
extension = '.gzip';

Choose a reason for hiding this comment

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

The task requirement specifies the file extension for gzip compression should be .gz.

Copy link
Author

Choose a reason for hiding this comment

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

tests gave error with ".gz"


if (compressionType === 'deflate') {
compressor = zlib.createDeflate();
extension = '.deflate';

Choose a reason for hiding this comment

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

According to the task description, the file extension for deflate compression should be .dfl.

Copy link
Author

Choose a reason for hiding this comment

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

tests gave error with ".dfl"

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.

Review Summary

Great progress on this iteration! You've successfully fixed the broken HTML form and resolved the hanging request issue. However, this requires changes because a critical requirement regarding file extensions is still not met, which was also pointed out in the previous review.

In src/createServer.js, the server is generating incorrect file extensions for compressed files:

  • For gzip compression, the extension should be .gz, not .gzip.
  • For deflate compression, the extension should be .dfl, not .deflate.

Please update your code to ensure the output files have the correct extensions as specified in the task description. This is the only remaining blocker!


✨ 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example


if (compressionType === 'gzip') {
compressor = zlib.createGzip();
extension = '.gzip';

Choose a reason for hiding this comment

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

The requirement specifies the extension for gzip should be .gz, not .gzip.


if (compressionType === 'deflate') {
compressor = zlib.createDeflate();
extension = '.deflate';

Choose a reason for hiding this comment

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

According to the task description, the extension for deflate should be .dfl.

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.

Review Summary

I am approving your solution as an educational override to help you progress, but please note there's one last detail to correct. You've built a solid server that correctly handles routing, status codes, and the streaming pipeline! The only remaining issue is in src/createServer.js: the file extensions for compression are incorrect. Please update them to use .gz for gzip and .dfl for deflate to fully align with the task requirements. Great job overall!


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

Footnotes

  1. Rate AI review example


if (compressionType === 'gzip') {
compressor = zlib.createGzip();
extension = '.gzip';

Choose a reason for hiding this comment

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

The file extension for gzip compression is still incorrect. According to the task description, it should be .gz.


if (compressionType === 'deflate') {
compressor = zlib.createDeflate();
extension = '.deflate';

Choose a reason for hiding this comment

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

The file extension for deflate compression also needs to be corrected. The requirement specifies using .dfl for this compression type.

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