Skip to content

Solution#237

Open
Artemida1609 wants to merge 5 commits into
mate-academy:masterfrom
Artemida1609:develop
Open

Solution#237
Artemida1609 wants to merge 5 commits into
mate-academy:masterfrom
Artemida1609:develop

Conversation

@Artemida1609
Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings May 12, 2026 19:02
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements the Node.js HTTP server for the compression app: serves an HTML upload form at / and handles POST /compress by compressing the uploaded file via zlib and returning it as an attachment.

Changes:

  • Implemented createServer() with routing for / and /compress, plus multipart parsing and streaming compression response.
  • Updated tooling dependency @mate-academy/scripts and added busboy to dependencies.
  • Added a GitHub Actions workflow template file.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 6 comments.

File Description
src/createServer.js Adds server implementation, multipart parsing, and zlib-based compression response.
package.json Bumps @mate-academy/scripts and adds busboy dependency.
package-lock.json Lockfile updates for the dependency changes (@mate-academy/scripts, busboy, transitive deps).
.github/workflows/test.yml-template Adds a workflow “template” duplicating the existing CI workflow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/createServer.js
Comment thread src/createServer.js
Comment on lines +7 to +15
function parseMultipart(req, callback) {
const contentType = req.headers['content-type'] || '';
const boundaryMatch = contentType.match(/boundary=(.+)$/);

if (!boundaryMatch) {
return callback(new Error('No boundary'), null);
}

const boundary = boundaryMatch[1];
Comment thread src/createServer.js
Comment on lines +182 to +187
const { create, ext } = COMPRESSION_MAP[compressionType];
const outputFilename = `${file.filename}.${ext}`;

res.writeHead(200, {
'Content-Disposition': `attachment; filename=${outputFilename}`,
});
Comment thread src/createServer.js
Comment on lines +189 to +193
// Крок 6: Стискаємо через Stream
// file.data — це Buffer; перетворюємо на Readable stream
const { Readable } = require('stream');
const readable = new Readable();

Comment thread package.json
Comment on lines +33 to +35
},
"dependencies": {
"busboy": "^1.6.0"
Comment thread .github/workflows/test.yml-template Outdated
Comment on lines +1 to +23
name: Test

on:
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
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

Your implementation fully satisfies all task requirements. The code correctly handles multipart form uploads with a file input and compression type selector, implements Stream-based compression using the zlib module for all three formats (gzip, deflate, brotli), and returns appropriate HTTP status codes (200, 400, 404) for all scenarios. Note that the only CI failure was in the artifact cleanup job due to a GitHub Actions cross-repository permission issue—this is unrelated to your code and does not block your submission. Your solution is approved.


✨ 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

Artemida1609 and others added 4 commits May 12, 2026 21:21
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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

Your implementation fully satisfies all task requirements. The solution correctly implements a multipart form handler with file upload, includes a file input (name="file"), a select field with compression options (gzip, deflate, br), and properly handles all HTTP status codes (200 for success, 400 for invalid requests, 404 for non-existent endpoints). The compression is implemented using Node.js Streams with the zlib module, and output files are generated with the correct extensions (.gz, .dfl, .br). All specified requirements are met, and there are no critical issues that need to be addressed.


✨ 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.

3 participants