Skip to content

solution#217

Open
Nazarii-Lesniak wants to merge 3 commits intomate-academy:masterfrom
Nazarii-Lesniak:develop
Open

solution#217
Nazarii-Lesniak wants to merge 3 commits intomate-academy:masterfrom
Nazarii-Lesniak:develop

Conversation

@Nazarii-Lesniak
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@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 job setting up the server and implementing the core compression logic using streams and the zlib module! Your code handles most of the routing requirements correctly. However, a couple of critical issues need to be addressed before this can be approved. Here are the required changes:

  1. Server Stability: The application currently crashes if a POST request is sent to /compress without a valid content-type header. You should add a check to ensure the header exists and is well-formed before trying to parse it. If it's invalid, the server should respond with a 400 status code as per the requirements.
  2. File Naming: The compressed files are being saved with incorrect extensions. The task requires .gz for gzip and .dfl for deflate, but your code is generating .gzip and .deflate. Please map the compression types to their correct, shorter extensions.

Once these issues are fixed, your solution will be in great shape. Keep up the good work!


✨ 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 (request.method === 'POST') {
const boundary = request.headers['content-type'].split('boundary=')[1];
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 application could crash if the 'content-type' header is missing or doesn't contain a boundary. It's important to validate the header before attempting to access its properties. According to the requirements, the server should handle this as an invalid form submission and respond with a 400 status code.

compressedStream = zlib.createBrotliCompress();
}

const newFileName = `${fileName}.${compressionType}`;
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 task description requires the file extensions to be .gz, .dfl, and .br for gzip, deflate, and br compression types respectively. This line appends the full compression type name as the extension, resulting in incorrect extensions like .gzip and .deflate. You should map the compression type to the correct file extension.

Copy link
Copy Markdown

@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

Excellent work! I am approving your solution as you've successfully addressed all the feedback from the previous review and met all the task requirements. The server now correctly handles the content-type header and uses the proper file extensions for compressed files. Your implementation of Node.js streams and the zlib module is solid and the code is clean. Great job!


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

Footnotes

  1. Rate AI review example

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