Skip to content
Open

Dev #200

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/test.yml-template
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
57 changes: 41 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"devDependencies": {
"@faker-js/faker": "^8.4.1",
"@mate-academy/eslint-config": "latest",
"@mate-academy/scripts": "^1.8.6",
"@mate-academy/scripts": "^2.1.3",
"axios": "^1.7.2",
"eslint": "^8.57.0",
"eslint-plugin-jest": "^28.6.0",
Expand All @@ -30,5 +30,8 @@
},
"mateAcademy": {
"projectType": "javascript"
},
"dependencies": {
"busboy": "^1.6.0"
}
}
67 changes: 67 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
'use strict';

const endpoints = {
home: '/',
compress: '/compress',
};

const compMethods = {
gzip: 'gzip',
deflate: 'deflate',
brotli: 'br',
};

const htmlNames = {
comp: 'compressionType',
file: 'file',
};

const index = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Compression app</title>
</head>
<body>

<form
action="${endpoints.compress}?${htmlNames.comp}=${compMethods.gzip}"
method="post"
enctype="multipart/form-data"
>

Comment on lines +32 to +34
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 display text for these options is currently the same as their value. If you update the values to be the required file extensions (e.g., 'gz'), the user will see these short extensions in the dropdown. For better user experience, consider hardcoding the full names (gzip, deflate, brotli) as the display text while using the shorter extensions for the value attribute.

<label>
Compression:
<select name="${htmlNames.comp}" required onChange="updateAction(this.value)">
<option value="${compMethods.gzip}" selected>${compMethods.gzip}</option>
<option value="${compMethods.deflate}">${compMethods.deflate}</option>
<option value="${compMethods.brotli}">${compMethods.brotli}</option>
</select>
</label>

<label>
File:
<input type="file" name="${htmlNames.file}" required>
</label>

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

<script>
function updateAction(type) {
document.querySelector('form').action =
'${endpoints.compress}?${htmlNames.comp}=' + type;
}
</script>
</body>
</html>
`;

module.exports = {
endpoints,
compMethods,
htmlNames,
index,
};
Loading
Loading