Solution#237
Conversation
There was a problem hiding this comment.
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/scriptsand addedbusboyto 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.
| 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]; |
| const { create, ext } = COMPRESSION_MAP[compressionType]; | ||
| const outputFilename = `${file.filename}.${ext}`; | ||
|
|
||
| res.writeHead(200, { | ||
| 'Content-Disposition': `attachment; filename=${outputFilename}`, | ||
| }); |
| // Крок 6: Стискаємо через Stream | ||
| // file.data — це Buffer; перетворюємо на Readable stream | ||
| const { Readable } = require('stream'); | ||
| const readable = new Readable(); | ||
|
|
| }, | ||
| "dependencies": { | ||
| "busboy": "^1.6.0" |
| 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 |
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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! ✨
No description provided.