From 23b5dfe545ae37e599e7971c3dee2e314eaa9c08 Mon Sep 17 00:00:00 2001 From: Tester Date: Fri, 30 Jan 2026 18:50:43 +0100 Subject: [PATCH 1/7] Add initial assignments --- .gitignore | 4 +- .hyf/score.example.json | 5 - .hyf/test.sh | 17 +- .hyf/tester.js | 55 ++ .vscode/settings.json | 6 + package-lock.json | 1468 +++++++++++++++++++++++++++++++++++++++ package.json | 16 + task-1/task 1 files | 0 task-1/task1-a.sh | 3 + task-1/task1-b.sh | 4 + task-2/fetcher.js | 25 + task-2/index.html | 73 ++ task-2/index.js | 16 + task-2/services.js | 22 + task-2/styles.css | 384 ++++++++++ task-2/task 2 files | 0 task-2/ui.js | 382 ++++++++++ tests/task1-a.test.js | 20 + tests/task1-b.test.js | 18 + 19 files changed, 2502 insertions(+), 16 deletions(-) delete mode 100644 .hyf/score.example.json create mode 100644 .hyf/tester.js create mode 100644 .vscode/settings.json create mode 100644 package-lock.json create mode 100644 package.json delete mode 100644 task-1/task 1 files create mode 100644 task-1/task1-a.sh create mode 100644 task-1/task1-b.sh create mode 100644 task-2/fetcher.js create mode 100644 task-2/index.html create mode 100644 task-2/index.js create mode 100644 task-2/services.js create mode 100644 task-2/styles.css delete mode 100644 task-2/task 2 files create mode 100644 task-2/ui.js create mode 100644 tests/task1-a.test.js create mode 100644 tests/task1-b.test.js diff --git a/.gitignore b/.gitignore index 2b76d7c..ef0601d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,8 @@ Thumbs.db .hyf/score.json # Editor and IDE settings -.vscode/ +# Commit .vscode with settings to disable GitHub Copilot +# .vscode/ .idea/ *.iml *.code-workspace @@ -156,3 +157,4 @@ dist vite.config.js.timestamp-* vite.config.ts.timestamp-* +task-2/services-solution.js diff --git a/.hyf/score.example.json b/.hyf/score.example.json deleted file mode 100644 index 8d931f5..0000000 --- a/.hyf/score.example.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "score": 75, - "pass": true, - "passingScore": 50 -} \ No newline at end of file diff --git a/.hyf/test.sh b/.hyf/test.sh index ee037fc..85b02d8 100644 --- a/.hyf/test.sh +++ b/.hyf/test.sh @@ -1,13 +1,10 @@ #!/usr/bin/env bash -set -euo pipefail -# Run your test scripts here. -# Auto grade tool will execute this file within the .hyf working directory. -# The result should be stored in score.json file with the format shown below. -cat << EOF > score.json { - "score": 0, - "pass": true, - "passingScore": 0 -} -EOF + pushd .. + /usr/bin/env npm install + npx vitest run --reporter=json --outputFile=.hyf/report.json + popd || exit +} >/dev/null + +PASSING_SCORE=50 /usr/bin/env node tester.js diff --git a/.hyf/tester.js b/.hyf/tester.js new file mode 100644 index 0000000..624a9cd --- /dev/null +++ b/.hyf/tester.js @@ -0,0 +1,55 @@ +import fs from 'fs/promises'; +import path from 'path'; + +const __dirname = import.meta.dirname; +const reportPath = path.join(__dirname, 'report.json'); + +try { + const reportContent = await fs.readFile(reportPath, 'utf-8'); + await fs.unlink(reportPath); + + const { testResults } = JSON.parse(reportContent); + let maxPoints = 0; + let earnedPoints = 0; + let passedCount = 0; + let failedCount = 0; + + console.log('Vitest unit test results:\n'); + + const passingScore = Number(process.env.PASSING_SCORE || 50); + + for (const result of testResults) { + for (const { title, status } of result.assertionResults) { + const match = title.match(/^\[(\d+)]/); + const points = match ? Number(match[1]) || 1 : 1; + maxPoints += points; + let icon; + if (status === 'passed') { + icon = '✅'; + passedCount += 1; + earnedPoints += points; + } else { + icon = '❌'; + failedCount += 1; + } + console.log(`${icon} ${title}`); + } + } + + console.log(`\nTotal passed: ${passedCount}`); + console.log(`Total failed: ${failedCount}`); + + const totalScore = Math.round((earnedPoints / maxPoints) * 100); + + const results = { + score: totalScore, + pass: totalScore >= passingScore, + passingScore: passingScore, + }; + + await fs.writeFile('score.json', JSON.stringify(results, null, 2)); + process.exit(0); +} catch (error) { + console.error('Error parsing report JSON:', error); + process.exit(1); +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0c13e99 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "editor.inlineSuggest.enabled": false, + "github.copilot.enable": { + "javascript": false + } +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..46593b2 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1468 @@ +{ + "name": "core-assignment-week-10", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "core-assignment-week-10", + "version": "1.0.0", + "license": "ISC", + "devDependencies": { + "vitest": "^4.0.17" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.2.tgz", + "integrity": "sha512-GZMB+a0mOMZs4MpDbj8RJp4cw+w1WV5NYD6xzgvzUJ5Ek2jerwfO2eADyI6ExDSUED+1X8aMbegahsJi+8mgpw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.2.tgz", + "integrity": "sha512-DVNI8jlPa7Ujbr1yjU2PfUSRtAUZPG9I1RwW4F4xFB1Imiu2on0ADiI/c3td+KmDtVKNbi+nffGDQMfcIMkwIA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.2.tgz", + "integrity": "sha512-pvz8ZZ7ot/RBphf8fv60ljmaoydPU12VuXHImtAs0XhLLw+EXBi2BLe3OYSBslR4rryHvweW5gmkKFwTiFy6KA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.2.tgz", + "integrity": "sha512-z8Ank4Byh4TJJOh4wpz8g2vDy75zFL0TlZlkUkEwYXuPSgX8yzep596n6mT7905kA9uHZsf/o2OJZubl2l3M7A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.2.tgz", + "integrity": "sha512-davCD2Zc80nzDVRwXTcQP/28fiJbcOwvdolL0sOiOsbwBa72kegmVU0Wrh1MYrbuCL98Omp5dVhQFWRKR2ZAlg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.2.tgz", + "integrity": "sha512-ZxtijOmlQCBWGwbVmwOF/UCzuGIbUkqB1faQRf5akQmxRJ1ujusWsb3CVfk/9iZKr2L5SMU5wPBi1UWbvL+VQA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.2.tgz", + "integrity": "sha512-lS/9CN+rgqQ9czogxlMcBMGd+l8Q3Nj1MFQwBZJyoEKI50XGxwuzznYdwcav6lpOGv5BqaZXqvBSiB/kJ5op+g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.2.tgz", + "integrity": "sha512-tAfqtNYb4YgPnJlEFu4c212HYjQWSO/w/h/lQaBK7RbwGIkBOuNKQI9tqWzx7Wtp7bTPaGC6MJvWI608P3wXYA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.2.tgz", + "integrity": "sha512-vWfq4GaIMP9AIe4yj1ZUW18RDhx6EPQKjwe7n8BbIecFtCQG4CfHGaHuh7fdfq+y3LIA2vGS/o9ZBGVxIDi9hw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.2.tgz", + "integrity": "sha512-hYxN8pr66NsCCiRFkHUAsxylNOcAQaxSSkHMMjcpx0si13t1LHFphxJZUiGwojB1a/Hd5OiPIqDdXONia6bhTw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.2.tgz", + "integrity": "sha512-MJt5BRRSScPDwG2hLelYhAAKh9imjHK5+NE/tvnRLbIqUWa+0E9N4WNMjmp/kXXPHZGqPLxggwVhz7QP8CTR8w==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.2.tgz", + "integrity": "sha512-lugyF1atnAT463aO6KPshVCJK5NgRnU4yb3FUumyVz+cGvZbontBgzeGFO1nF+dPueHD367a2ZXe1NtUkAjOtg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.2.tgz", + "integrity": "sha512-nlP2I6ArEBewvJ2gjrrkESEZkB5mIoaTswuqNFRv/WYd+ATtUpe9Y09RnJvgvdag7he0OWgEZWhviS1OTOKixw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.2.tgz", + "integrity": "sha512-C92gnpey7tUQONqg1n6dKVbx3vphKtTHJaNG2Ok9lGwbZil6DrfyecMsp9CrmXGQJmZ7iiVXvvZH6Ml5hL6XdQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.2.tgz", + "integrity": "sha512-B5BOmojNtUyN8AXlK0QJyvjEZkWwy/FKvakkTDCziX95AowLZKR6aCDhG7LeF7uMCXEJqwa8Bejz5LTPYm8AvA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.2.tgz", + "integrity": "sha512-p4bm9+wsPwup5Z8f4EpfN63qNagQ47Ua2znaqGH6bqLlmJ4bx97Y9JdqxgGZ6Y8xVTixUnEkoKSHcpRlDnNr5w==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.2.tgz", + "integrity": "sha512-uwp2Tip5aPmH+NRUwTcfLb+W32WXjpFejTIOWZFw/v7/KnpCDKG66u4DLcurQpiYTiYwQ9B7KOeMJvLCu/OvbA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.2.tgz", + "integrity": "sha512-Kj6DiBlwXrPsCRDeRvGAUb/LNrBASrfqAIok+xB0LxK8CHqxZ037viF13ugfsIpePH93mX7xfJp97cyDuTZ3cw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.2.tgz", + "integrity": "sha512-HwGDZ0VLVBY3Y+Nw0JexZy9o/nUAWq9MlV7cahpaXKW6TOzfVno3y3/M8Ga8u8Yr7GldLOov27xiCnqRZf0tCA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.2.tgz", + "integrity": "sha512-DNIHH2BPQ5551A7oSHD0CKbwIA/Ox7+78/AWkbS5QoRzaqlev2uFayfSxq68EkonB+IKjiuxBFoV8ESJy8bOHA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.2.tgz", + "integrity": "sha512-/it7w9Nb7+0KFIzjalNJVR5bOzA9Vay+yIPLVHfIQYG/j+j9VTH84aNB8ExGKPU4AzfaEvN9/V4HV+F+vo8OEg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.2.tgz", + "integrity": "sha512-LRBbCmiU51IXfeXk59csuX/aSaToeG7w48nMwA6049Y4J4+VbWALAuXcs+qcD04rHDuSCSRKdmY63sruDS5qag==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.2.tgz", + "integrity": "sha512-kMtx1yqJHTmqaqHPAzKCAkDaKsffmXkPHThSfRwZGyuqyIeBvf08KSsYXl+abf5HDAPMJIPnbBfXvP2ZC2TfHg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.2.tgz", + "integrity": "sha512-Yaf78O/B3Kkh+nKABUF++bvJv5Ijoy9AN1ww904rOXZFLWVc5OLOfL56W+C8F9xn5JQZa3UX6m+IktJnIb1Jjg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.2.tgz", + "integrity": "sha512-Iuws0kxo4yusk7sw70Xa2E2imZU5HoixzxfGCdxwBdhiDgt9vX9VUCBhqcwY7/uh//78A1hMkkROMJq9l27oLQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.2.tgz", + "integrity": "sha512-sRdU18mcKf7F+YgheI/zGf5alZatMUTKj/jNS6l744f9u3WFu4v7twcUI9vu4mknF4Y9aDlblIie0IM+5xxaqQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "dev": true, + "license": "MIT" + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.57.1.tgz", + "integrity": "sha512-A6ehUVSiSaaliTxai040ZpZ2zTevHYbvu/lDoeAteHI8QnaosIzm4qwtezfRg1jOYaUmnzLX1AOD6Z+UJjtifg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.57.1.tgz", + "integrity": "sha512-dQaAddCY9YgkFHZcFNS/606Exo8vcLHwArFZ7vxXq4rigo2bb494/xKMMwRRQW6ug7Js6yXmBZhSBRuBvCCQ3w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.57.1.tgz", + "integrity": "sha512-crNPrwJOrRxagUYeMn/DZwqN88SDmwaJ8Cvi/TN1HnWBU7GwknckyosC2gd0IqYRsHDEnXf328o9/HC6OkPgOg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.57.1.tgz", + "integrity": "sha512-Ji8g8ChVbKrhFtig5QBV7iMaJrGtpHelkB3lsaKzadFBe58gmjfGXAOfI5FV0lYMH8wiqsxKQ1C9B0YTRXVy4w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.57.1.tgz", + "integrity": "sha512-R+/WwhsjmwodAcz65guCGFRkMb4gKWTcIeLy60JJQbXrJ97BOXHxnkPFrP+YwFlaS0m+uWJTstrUA9o+UchFug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.57.1.tgz", + "integrity": "sha512-IEQTCHeiTOnAUC3IDQdzRAGj3jOAYNr9kBguI7MQAAZK3caezRrg0GxAb6Hchg4lxdZEI5Oq3iov/w/hnFWY9Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.57.1.tgz", + "integrity": "sha512-F8sWbhZ7tyuEfsmOxwc2giKDQzN3+kuBLPwwZGyVkLlKGdV1nvnNwYD0fKQ8+XS6hp9nY7B+ZeK01EBUE7aHaw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.57.1.tgz", + "integrity": "sha512-rGfNUfn0GIeXtBP1wL5MnzSj98+PZe/AXaGBCRmT0ts80lU5CATYGxXukeTX39XBKsxzFpEeK+Mrp9faXOlmrw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.57.1.tgz", + "integrity": "sha512-MMtej3YHWeg/0klK2Qodf3yrNzz6CGjo2UntLvk2RSPlhzgLvYEB3frRvbEF2wRKh1Z2fDIg9KRPe1fawv7C+g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.57.1.tgz", + "integrity": "sha512-1a/qhaaOXhqXGpMFMET9VqwZakkljWHLmZOX48R0I/YLbhdxr1m4gtG1Hq7++VhVUmf+L3sTAf9op4JlhQ5u1Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.57.1.tgz", + "integrity": "sha512-QWO6RQTZ/cqYtJMtxhkRkidoNGXc7ERPbZN7dVW5SdURuLeVU7lwKMpo18XdcmpWYd0qsP1bwKPf7DNSUinhvA==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.57.1.tgz", + "integrity": "sha512-xpObYIf+8gprgWaPP32xiN5RVTi/s5FCR+XMXSKmhfoJjrpRAjCuuqQXyxUa/eJTdAE6eJ+KDKaoEqjZQxh3Gw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.57.1.tgz", + "integrity": "sha512-4BrCgrpZo4hvzMDKRqEaW1zeecScDCR+2nZ86ATLhAoJ5FQ+lbHVD3ttKe74/c7tNT9c6F2viwB3ufwp01Oh2w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.57.1.tgz", + "integrity": "sha512-NOlUuzesGauESAyEYFSe3QTUguL+lvrN1HtwEEsU2rOwdUDeTMJdO5dUYl/2hKf9jWydJrO9OL/XSSf65R5+Xw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.57.1.tgz", + "integrity": "sha512-ptA88htVp0AwUUqhVghwDIKlvJMD/fmL/wrQj99PRHFRAG6Z5nbWoWG4o81Nt9FT+IuqUQi+L31ZKAFeJ5Is+A==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.57.1.tgz", + "integrity": "sha512-S51t7aMMTNdmAMPpBg7OOsTdn4tySRQvklmL3RpDRyknk87+Sp3xaumlatU+ppQ+5raY7sSTcC2beGgvhENfuw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.57.1.tgz", + "integrity": "sha512-Bl00OFnVFkL82FHbEqy3k5CUCKH6OEJL54KCyx2oqsmZnFTR8IoNqBF+mjQVcRCT5sB6yOvK8A37LNm/kPJiZg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.57.1.tgz", + "integrity": "sha512-ABca4ceT4N+Tv/GtotnWAeXZUZuM/9AQyCyKYyKnpk4yoA7QIAuBt6Hkgpw8kActYlew2mvckXkvx0FfoInnLg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.57.1.tgz", + "integrity": "sha512-HFps0JeGtuOR2convgRRkHCekD7j+gdAuXM+/i6kGzQtFhlCtQkpwtNzkNj6QhCDp7DRJ7+qC/1Vg2jt5iSOFw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.57.1.tgz", + "integrity": "sha512-H+hXEv9gdVQuDTgnqD+SQffoWoc0Of59AStSzTEj/feWTBAnSfSD3+Dql1ZruJQxmykT/JVY0dE8Ka7z0DH1hw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.57.1.tgz", + "integrity": "sha512-4wYoDpNg6o/oPximyc/NG+mYUejZrCU2q+2w6YZqrAs2UcNUChIZXjtafAiiZSUc7On8v5NyNj34Kzj/Ltk6dQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.57.1.tgz", + "integrity": "sha512-O54mtsV/6LW3P8qdTcamQmuC990HDfR71lo44oZMZlXU4tzLrbvTii87Ni9opq60ds0YzuAlEr/GNwuNluZyMQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.57.1.tgz", + "integrity": "sha512-P3dLS+IerxCT/7D2q2FYcRdWRl22dNbrbBEtxdWhXrfIMPP9lQhb5h4Du04mdl5Woq05jVCDPCMF7Ub0NAjIew==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.57.1.tgz", + "integrity": "sha512-VMBH2eOOaKGtIJYleXsi2B8CPVADrh+TyNxJ4mWPnKfLB/DBUmzW+5m1xUrcwWoMfSLagIRpjUFeW5CO5hyciQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.57.1.tgz", + "integrity": "sha512-mxRFDdHIWRxg3UfIIAwCm6NzvxG0jDX/wBN6KsQFTvKFqqg9vTrWUE68qEjHt19A5wwx5X5aUi2zuZT7YR0jrA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@standard-schema/spec": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", + "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@vitest/expect": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.0.18.tgz", + "integrity": "sha512-8sCWUyckXXYvx4opfzVY03EOiYVxyNrHS5QxX3DAIi5dpJAAkyJezHCP77VMX4HKA2LDT/Jpfo8i2r5BE3GnQQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@standard-schema/spec": "^1.0.0", + "@types/chai": "^5.2.2", + "@vitest/spy": "4.0.18", + "@vitest/utils": "4.0.18", + "chai": "^6.2.1", + "tinyrainbow": "^3.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.0.18.tgz", + "integrity": "sha512-HhVd0MDnzzsgevnOWCBj5Otnzobjy5wLBe4EdeeFGv8luMsGcYqDuFRMcttKWZA5vVO8RFjexVovXvAM4JoJDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "4.0.18", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.21" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^6.0.0 || ^7.0.0-0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/pretty-format": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.0.18.tgz", + "integrity": "sha512-P24GK3GulZWC5tz87ux0m8OADrQIUVDPIjjj65vBXYG17ZeU3qD7r+MNZ1RNv4l8CGU2vtTRqixrOi9fYk/yKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^3.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.0.18.tgz", + "integrity": "sha512-rpk9y12PGa22Jg6g5M3UVVnTS7+zycIGk9ZNGN+m6tZHKQb7jrP7/77WfZy13Y/EUDd52NDsLRQhYKtv7XfPQw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "4.0.18", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.0.18.tgz", + "integrity": "sha512-PCiV0rcl7jKQjbgYqjtakly6T1uwv/5BQ9SwBLekVg/EaYeQFPiXcgrC2Y7vDMA8dM1SUEAEV82kgSQIlXNMvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "4.0.18", + "magic-string": "^0.30.21", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.0.18.tgz", + "integrity": "sha512-cbQt3PTSD7P2OARdVW3qWER5EGq7PHlvE+QfzSC0lbwO+xnt7+XH06ZzFjFRgzUX//JmpxrCu92VdwvEPlWSNw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.0.18.tgz", + "integrity": "sha512-msMRKLMVLWygpK3u2Hybgi4MNjcYJvwTb0Ru09+fOyCXIgT5raYP041DRRdiJiI3k/2U6SEbAETB3YtBrUkCFA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "4.0.18", + "tinyrainbow": "^3.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/chai": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz", + "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/es-module-lexer": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", + "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==", + "dev": true, + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.2.tgz", + "integrity": "sha512-HyNQImnsOC7X9PMNaCIeAm4ISCQXs5a5YasTXVliKv4uuBo1dKrG0A+uQS8M5eXjVMnLg3WgXaKvprHlFJQffw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.27.2", + "@esbuild/android-arm": "0.27.2", + "@esbuild/android-arm64": "0.27.2", + "@esbuild/android-x64": "0.27.2", + "@esbuild/darwin-arm64": "0.27.2", + "@esbuild/darwin-x64": "0.27.2", + "@esbuild/freebsd-arm64": "0.27.2", + "@esbuild/freebsd-x64": "0.27.2", + "@esbuild/linux-arm": "0.27.2", + "@esbuild/linux-arm64": "0.27.2", + "@esbuild/linux-ia32": "0.27.2", + "@esbuild/linux-loong64": "0.27.2", + "@esbuild/linux-mips64el": "0.27.2", + "@esbuild/linux-ppc64": "0.27.2", + "@esbuild/linux-riscv64": "0.27.2", + "@esbuild/linux-s390x": "0.27.2", + "@esbuild/linux-x64": "0.27.2", + "@esbuild/netbsd-arm64": "0.27.2", + "@esbuild/netbsd-x64": "0.27.2", + "@esbuild/openbsd-arm64": "0.27.2", + "@esbuild/openbsd-x64": "0.27.2", + "@esbuild/openharmony-arm64": "0.27.2", + "@esbuild/sunos-x64": "0.27.2", + "@esbuild/win32-arm64": "0.27.2", + "@esbuild/win32-ia32": "0.27.2", + "@esbuild/win32-x64": "0.27.2" + } + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/expect-type": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.3.0.tgz", + "integrity": "sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/obug": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.1.tgz", + "integrity": "sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT" + }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/rollup": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.57.1.tgz", + "integrity": "sha512-oQL6lgK3e2QZeQ7gcgIkS2YZPg5slw37hYufJ3edKlfQSGGm8ICoxswK15ntSzF/a8+h7ekRy7k7oWc3BQ7y8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.8" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.57.1", + "@rollup/rollup-android-arm64": "4.57.1", + "@rollup/rollup-darwin-arm64": "4.57.1", + "@rollup/rollup-darwin-x64": "4.57.1", + "@rollup/rollup-freebsd-arm64": "4.57.1", + "@rollup/rollup-freebsd-x64": "4.57.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.57.1", + "@rollup/rollup-linux-arm-musleabihf": "4.57.1", + "@rollup/rollup-linux-arm64-gnu": "4.57.1", + "@rollup/rollup-linux-arm64-musl": "4.57.1", + "@rollup/rollup-linux-loong64-gnu": "4.57.1", + "@rollup/rollup-linux-loong64-musl": "4.57.1", + "@rollup/rollup-linux-ppc64-gnu": "4.57.1", + "@rollup/rollup-linux-ppc64-musl": "4.57.1", + "@rollup/rollup-linux-riscv64-gnu": "4.57.1", + "@rollup/rollup-linux-riscv64-musl": "4.57.1", + "@rollup/rollup-linux-s390x-gnu": "4.57.1", + "@rollup/rollup-linux-x64-gnu": "4.57.1", + "@rollup/rollup-linux-x64-musl": "4.57.1", + "@rollup/rollup-openbsd-x64": "4.57.1", + "@rollup/rollup-openharmony-arm64": "4.57.1", + "@rollup/rollup-win32-arm64-msvc": "4.57.1", + "@rollup/rollup-win32-ia32-msvc": "4.57.1", + "@rollup/rollup-win32-x64-gnu": "4.57.1", + "@rollup/rollup-win32-x64-msvc": "4.57.1", + "fsevents": "~2.3.2" + } + }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true, + "license": "ISC" + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/std-env": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz", + "integrity": "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyexec": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.2.tgz", + "integrity": "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyrainbow": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.0.3.tgz", + "integrity": "sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/vite": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.1.tgz", + "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "esbuild": "^0.27.0", + "fdir": "^6.5.0", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "lightningcss": "^1.21.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vitest": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.0.18.tgz", + "integrity": "sha512-hOQuK7h0FGKgBAas7v0mSAsnvrIgAvWmRFjmzpJ7SwFHH3g1k2u37JtYwOwmEKhK6ZO3v9ggDBBm0La1LCK4uQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/expect": "4.0.18", + "@vitest/mocker": "4.0.18", + "@vitest/pretty-format": "4.0.18", + "@vitest/runner": "4.0.18", + "@vitest/snapshot": "4.0.18", + "@vitest/spy": "4.0.18", + "@vitest/utils": "4.0.18", + "es-module-lexer": "^1.7.0", + "expect-type": "^1.2.2", + "magic-string": "^0.30.21", + "obug": "^2.1.1", + "pathe": "^2.0.3", + "picomatch": "^4.0.3", + "std-env": "^3.10.0", + "tinybench": "^2.9.0", + "tinyexec": "^1.0.2", + "tinyglobby": "^0.2.15", + "tinyrainbow": "^3.0.3", + "vite": "^6.0.0 || ^7.0.0", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^20.0.0 || ^22.0.0 || >=24.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@opentelemetry/api": "^1.9.0", + "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "4.0.18", + "@vitest/browser-preview": "4.0.18", + "@vitest/browser-webdriverio": "4.0.18", + "@vitest/ui": "4.0.18", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@opentelemetry/api": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser-playwright": { + "optional": true + }, + "@vitest/browser-preview": { + "optional": true + }, + "@vitest/browser-webdriverio": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..197c991 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "core-assignment-week-10", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "vitest" + }, + "keywords": [], + "author": "", + "license": "ISC", + "type": "module", + "devDependencies": { + "vitest": "^4.0.17" + } +} diff --git a/task-1/task 1 files b/task-1/task 1 files deleted file mode 100644 index e69de29..0000000 diff --git a/task-1/task1-a.sh b/task-1/task1-a.sh new file mode 100644 index 0000000..c948e5d --- /dev/null +++ b/task-1/task1-a.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +curl https://jsonplaceholder.typicode.com/todos/1 diff --git a/task-1/task1-b.sh b/task-1/task1-b.sh new file mode 100644 index 0000000..b184949 --- /dev/null +++ b/task-1/task1-b.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +curl https://date.nager.at/api/v3/CountryInfo/nl \ + --header 'Accept: */*' diff --git a/task-2/fetcher.js b/task-2/fetcher.js new file mode 100644 index 0000000..96895c7 --- /dev/null +++ b/task-2/fetcher.js @@ -0,0 +1,25 @@ +/** + * Fetch data from a given URL and handle success and error via callbacks. + * @param {string} url The URL to fetch data from + * @param {Function} onSuccess Called with data for successful fetch + * @param {Function} onError Called with an Error object for fetch errors + */ +export function fetchData(url, onSuccess, onError) { + fetch(url) + .then((response) => { + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + return response.json(); + }) + .then((data) => { + if (onSuccess) { + onSuccess(data); + } + }) + .catch((error) => { + if (onError) { + onError(error); + } + }); +} diff --git a/task-2/index.html b/task-2/index.html new file mode 100644 index 0000000..b517ec6 --- /dev/null +++ b/task-2/index.html @@ -0,0 +1,73 @@ + + + + + + Nobel Prize Explorer + + + +
+
+

🏆 Nobel Prize Explorer

+

Explore Nobel Prize winners through history

+
+ +
+
+ + +
+ +
+ + +
+
+ +
+
+
+
+ +
+ 0 prizes found +
+ +
+ + +
+ + + + diff --git a/task-2/index.js b/task-2/index.js new file mode 100644 index 0000000..6c4d45e --- /dev/null +++ b/task-2/index.js @@ -0,0 +1,16 @@ +import UI from './ui.js'; + +/** + * Main function to initialize the Nobel Prize Explorer application + */ +function main() { + const ui = new UI(); + ui.initialize(); + + console.log('Nobel Prize Explorer initialized'); + console.log( + 'API Documentation: https://www.nobelprize.org/about/developer-zone-2/' + ); +} + +window.addEventListener('load', main); diff --git a/task-2/services.js b/task-2/services.js new file mode 100644 index 0000000..45a551c --- /dev/null +++ b/task-2/services.js @@ -0,0 +1,22 @@ +// Nobel Prize API Documentation: https://www.nobelprize.org/about/developer-zone-2/ + +import { fetchData } from './fetcher.js'; + +const API_BASE_URL = 'https://api.nobelprize.org/2.1'; + +/** + * Fetch Nobel Prizes with optional filters + * @param {Object} filters - Filter options + * @param {string} filters.year - Year to filter by (optional) + * @param {string} filters.category - Category code to filter by (optional) + * @param {number} filters.offset - Pagination offset (default: 0) + * @param {number} filters.limit - Number of results per page (default: 10) + * @param {Function} onSuccess - Callback for successful fetch + * @param {Function} onError - Callback for fetch errors + */ +export function fetchNobelPrizes(filters = {}, onSuccess, onError) { + // TODO: Implement the function to fetch Nobel Prizes from the API + let url = API_BASE_URL; + + fetchData(url, onSuccess, onError); +} diff --git a/task-2/styles.css b/task-2/styles.css new file mode 100644 index 0000000..d9eb355 --- /dev/null +++ b/task-2/styles.css @@ -0,0 +1,384 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + background: linear-gradient(135deg, #1e3a8a 0%, #7c2d12 100%); + min-height: 100vh; + padding: 2rem; +} + +.container { + max-width: 1200px; + margin: 0 auto; +} + +header { + text-align: center; + color: white; + margin-bottom: 2rem; +} + +h1 { + font-size: 3rem; + margin-bottom: 0.5rem; + text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3); +} + +.subtitle { + font-size: 1.2rem; + opacity: 0.9; +} + +.filters { + background: rgba(255, 255, 255, 0.95); + border-radius: 12px; + padding: 1.5rem; + margin-bottom: 2rem; + display: flex; + justify-content: center; + align-items: center; + flex-wrap: wrap; + gap: 1.5rem; + box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); +} + +.filter-group { + display: flex; + align-items: center; + gap: 0.5rem; +} + +.filter-label { + font-size: 0.9rem; + color: #1e293b; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.5px; +} + +.filter-select { + padding: 0.6rem 1rem; + font-size: 1rem; + border: 2px solid #cbd5e1; + border-radius: 8px; + background: white; + color: #1e293b; + cursor: pointer; + transition: all 0.3s ease; + min-width: 160px; +} + +.filter-select:hover { + border-color: #3b82f6; +} + +.filter-select:focus { + outline: none; + border-color: #2563eb; + box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); +} + +.btn { + padding: 0.7rem 1.5rem; + font-size: 1rem; + font-weight: 600; + border: none; + border-radius: 8px; + cursor: pointer; + transition: all 0.3s ease; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); +} + +.btn:hover:not(:disabled) { + transform: translateY(-2px); + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); +} + +.btn:active:not(:disabled) { + transform: translateY(0); +} + +.btn:disabled { + opacity: 0.5; + cursor: not-allowed; +} + +.btn-primary { + background: linear-gradient(135deg, #10b981 0%, #059669 100%); + color: white; +} + +.btn-pagination { + background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); + color: white; + min-width: 120px; +} + +.loading { + position: fixed; + inset: 0; + display: none; + justify-content: center; + align-items: center; + background: rgba(15, 23, 42, 0.35); + -webkit-backdrop-filter: blur(2px); + backdrop-filter: blur(2px); + z-index: 1000; +} + +.loading.active { + display: flex; +} + +.spinner { + width: 48px; + height: 48px; + border: 5px solid rgba(255, 255, 255, 0.3); + border-top-color: #ffffff; + border-radius: 50%; + animation: spin 0.9s linear infinite; +} + +.error-message { + background: #fee; + color: #c53030; + padding: 1rem; + border-radius: 8px; + text-align: center; + display: none; + margin: 1rem 0; + border: 2px solid #fc8181; +} + +.error-message.active { + display: block; +} + +@keyframes spin { + to { + transform: rotate(360deg); + } +} + +.prizes-info { + color: white; + text-align: center; + font-size: 1.1rem; + margin-bottom: 1.5rem; + font-weight: 600; + text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3); +} + +#prizes-container { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); + gap: 1.5rem; + margin-bottom: 2rem; +} + +.prize-card { + background: white; + border-radius: 12px; + padding: 1.5rem; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + transition: all 0.3s ease; + border-left: 5px solid; +} + +.prize-card:hover { + transform: translateY(-5px); + box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); +} + +.prize-card.phy { + border-left-color: #3b82f6; +} + +.prize-card.che { + border-left-color: #10b981; +} + +.prize-card.med { + border-left-color: #ef4444; +} + +.prize-card.lit { + border-left-color: #f59e0b; +} + +.prize-card.pea { + border-left-color: #8b5cf6; +} + +.prize-card.eco { + border-left-color: #ec4899; +} + +.prize-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 1rem; + padding-bottom: 0.75rem; + border-bottom: 2px solid #e2e8f0; +} + +.prize-year { + font-size: 1.5rem; + font-weight: 700; + color: #1e293b; +} + +.prize-category { + font-size: 0.85rem; + font-weight: 600; + padding: 0.4rem 0.8rem; + border-radius: 6px; + text-transform: uppercase; + letter-spacing: 0.5px; + color: white; +} + +.prize-category.phy { + background: #3b82f6; +} + +.prize-category.che { + background: #10b981; +} + +.prize-category.med { + background: #ef4444; +} + +.prize-category.lit { + background: #f59e0b; +} + +.prize-category.pea { + background: #8b5cf6; +} + +.prize-category.eco { + background: #ec4899; +} + +.laureates-section { + margin-top: 1rem; +} + +.laureates-title { + font-size: 0.9rem; + font-weight: 600; + color: #64748b; + margin-bottom: 0.5rem; + text-transform: uppercase; + letter-spacing: 0.5px; +} + +.laureate-item { + margin-bottom: 0.75rem; + padding: 0.75rem; + background: #f8fafc; + border-radius: 6px; +} + +.laureate-name { + font-size: 1rem; + font-weight: 600; + color: #1e293b; + margin-bottom: 0.25rem; +} + +.laureate-motivation { + font-size: 0.875rem; + color: #64748b; + font-style: italic; + line-height: 1.4; +} + +.pagination { + display: flex; + justify-content: center; + align-items: center; + gap: 1.5rem; + margin-top: 2rem; + padding: 1.5rem; + background: rgba(255, 255, 255, 0.95); + border-radius: 12px; +} + +.page-info { + font-size: 1rem; + font-weight: 600; + color: #1e293b; + min-width: 120px; + text-align: center; +} + +.empty-state { + text-align: center; + color: white; + font-size: 1.2rem; + padding: 3rem; + background: rgba(255, 255, 255, 0.1); + border-radius: 12px; + margin: 2rem 0; +} + +@media (max-width: 768px) { + body { + padding: 1rem; + } + + h1 { + font-size: 2rem; + } + + .subtitle { + font-size: 1rem; + } + + .filters { + flex-direction: column; + align-items: stretch; + } + + .filter-group { + flex-direction: column; + align-items: stretch; + } + + .filter-select { + width: 100%; + } + + #prizes-container { + grid-template-columns: 1fr; + } + + .pagination { + flex-direction: column; + gap: 1rem; + } + + .btn-pagination { + width: 100%; + } +} + +@media (max-width: 480px) { + h1 { + font-size: 1.5rem; + } + + .prize-header { + flex-direction: column; + align-items: flex-start; + gap: 0.5rem; + } +} diff --git a/task-2/task 2 files b/task-2/task 2 files deleted file mode 100644 index e69de29..0000000 diff --git a/task-2/ui.js b/task-2/ui.js new file mode 100644 index 0000000..193f5fc --- /dev/null +++ b/task-2/ui.js @@ -0,0 +1,382 @@ +import { fetchNobelPrizes } from './services-solution.js'; + +export default class UI { + constructor() { + this.state = { + prizes: [], + currentPage: 1, + totalPrizes: 0, + itemsPerPage: 10, + filters: { + year: null, + category: 'all', + }, + }; + this.dom = this.getElementsWithIds(document); + } + + initialize() { + // Populate year select dropdown + this.populateYearSelect(); + + // Set up event listeners + this.dom.categorySelect.addEventListener('change', () => { + this.loadPrizes(); + }); + + this.dom.yearSelect.addEventListener('change', () => { + this.loadPrizes(); + }); + + this.dom.prevBtn.addEventListener('click', () => { + this.previousPage(); + }); + + this.dom.nextBtn.addEventListener('click', () => { + this.nextPage(); + }); + + this.dom.firstBtn.addEventListener('click', () => { + this.firstPage(); + }); + + this.dom.lastBtn.addEventListener('click', () => { + this.lastPage(); + }); + + // Load initial data + this.loadInitialData(); + } + + /** + * Get all elements with IDs and convert to camelCase object + */ + getElementsWithIds(root) { + const elements = root.querySelectorAll('[id]'); + return Array.from(elements).reduce((obj, element) => { + const name = element.id + .split('-') + .map((part, index) => { + if (index === 0) return part; + return part.charAt(0).toUpperCase() + part.slice(1); + }) + .join(''); + obj[name] = element; + return obj; + }, {}); + } + + /** + * Populate year select dropdown with years from 1901 to current year + */ + populateYearSelect() { + const currentYear = new Date().getFullYear(); + const startYear = 1901; + + // Add 'All' option first + const allOption = document.createElement('option'); + allOption.value = 'all'; + allOption.textContent = 'All'; + this.dom.yearSelect.appendChild(allOption); + + // Add years in descending order (newest first) + for (let year = currentYear; year >= startYear; year--) { + const option = document.createElement('option'); + option.value = year; + option.textContent = year; + this.dom.yearSelect.appendChild(option); + } + } + + /** + * Load initial data with 'All' years selected + */ + loadInitialData() { + // Set the initial year to 'all' in dropdown + this.dom.yearSelect.value = 'all'; + this.state.filters.year = 'all'; + + // Load prizes for all years + this.loadPrizes(); + } + + /** + * Load prizes based on current filters + */ + loadPrizes(page = 1) { + this.showLoading(); + + // Get filter values + const category = this.dom.categorySelect.value; + const year = this.dom.yearSelect.value; + + // Update state + this.state.filters.category = category; + this.state.filters.year = year; + this.state.currentPage = page; + + // Calculate offset + const offset = (page - 1) * this.state.itemsPerPage; + + // Fetch data + fetchNobelPrizes( + { + year: year, + category: category, + offset: offset, + limit: this.state.itemsPerPage, + }, + (data) => { + // Update state with results + this.state.prizes = data.nobelPrizes || []; + this.state.totalPrizes = data.meta?.count || 0; + + // Render results + this.renderPrizes(); + this.updatePagination(); + this.updatePrizesInfo(); + + this.hideLoading(); + }, + (error) => { + console.error('Error loading prizes:', error); + this.showError('Failed to load Nobel Prizes. Please try again.'); + this.hideLoading(); + } + ); + } + + /** + * Render prize cards + */ + renderPrizes() { + const container = this.dom.prizesContainer; + container.innerHTML = ''; + + if (this.state.prizes.length === 0) { + container.innerHTML = + '
No prizes found for the selected filters.
'; + return; + } + + this.state.prizes.forEach((prize) => { + const card = this.createPrizeCard(prize); + container.appendChild(card); + }); + } + + /** + * Create a prize card element + */ + createPrizeCard(prize) { + const card = document.createElement('div'); + const categoryCode = prize.categoryFullName?.en + ? this.getCategoryCode(prize.categoryFullName.en) + : 'phy'; + card.className = `prize-card ${categoryCode}`; + + // Create header + const header = document.createElement('div'); + header.className = 'prize-header'; + + const yearElement = document.createElement('div'); + yearElement.className = 'prize-year'; + yearElement.textContent = prize.awardYear || 'N/A'; + + const categoryElement = document.createElement('div'); + categoryElement.className = `prize-category ${categoryCode}`; + categoryElement.textContent = this.formatCategory( + prize.categoryFullName?.en || 'Unknown' + ); + + header.appendChild(yearElement); + header.appendChild(categoryElement); + + // Create laureates section + const laureatesSection = document.createElement('div'); + laureatesSection.className = 'laureates-section'; + + const laureatesTitle = document.createElement('div'); + laureatesTitle.className = 'laureates-title'; + laureatesTitle.textContent = 'Laureate(s):'; + + laureatesSection.appendChild(laureatesTitle); + + // Add each laureate + if (prize.laureates && prize.laureates.length > 0) { + prize.laureates.forEach((laureate) => { + const laureateItem = this.createLaureateItem(laureate); + laureatesSection.appendChild(laureateItem); + }); + } else { + const noLaureate = document.createElement('div'); + noLaureate.className = 'laureate-item'; + noLaureate.textContent = 'No laureates information available'; + laureatesSection.appendChild(noLaureate); + } + + card.appendChild(header); + card.appendChild(laureatesSection); + + return card; + } + + /** + * Create a laureate item element + */ + createLaureateItem(laureate) { + const item = document.createElement('div'); + item.className = 'laureate-item'; + + const nameElement = document.createElement('div'); + nameElement.className = 'laureate-name'; + + // Handle both individual and organization laureates + if (laureate.knownName) { + nameElement.textContent = laureate.knownName.en || 'Unknown'; + } else if (laureate.orgName) { + nameElement.textContent = laureate.orgName.en || 'Unknown Organization'; + } else if (laureate.fullName) { + nameElement.textContent = laureate.fullName.en || 'Unknown'; + } else { + nameElement.textContent = 'Unknown'; + } + + item.appendChild(nameElement); + + // Add motivation if available + if (laureate.motivation) { + const motivationElement = document.createElement('div'); + motivationElement.className = 'laureate-motivation'; + motivationElement.textContent = laureate.motivation.en || ''; + item.appendChild(motivationElement); + } + + return item; + } + + /** + * Get category code from full name + */ + getCategoryCode(categoryName) { + const mapping = { + Physics: 'phy', + Chemistry: 'che', + 'Physiology or Medicine': 'med', + Literature: 'lit', + Peace: 'pea', + 'Economic Sciences': 'eco', + }; + return mapping[categoryName] || 'phy'; + } + + /** + * Format category name for display + */ + formatCategory(categoryName) { + return categoryName + .replace('The Nobel Prize in ', '') + .replace('Physiology or ', ''); + } + + /** + * Update pagination controls + */ + updatePagination() { + const totalPages = Math.ceil( + this.state.totalPrizes / this.state.itemsPerPage + ); + const normalizedTotalPages = Math.max(totalPages, 1); + + // Update page info + this.dom.pageInfo.textContent = `Page ${this.state.currentPage} of ${normalizedTotalPages}`; + + // Update button states + this.dom.prevBtn.disabled = this.state.currentPage === 1; + this.dom.nextBtn.disabled = this.state.currentPage >= normalizedTotalPages; + this.dom.firstBtn.disabled = this.state.currentPage === 1; + this.dom.lastBtn.disabled = this.state.currentPage >= normalizedTotalPages; + } + + /** + * Update prizes count info + */ + updatePrizesInfo() { + const count = this.state.totalPrizes; + const plural = count !== 1 ? 'prizes' : 'prize'; + this.dom.prizesCount.textContent = `${count} ${plural} found`; + } + + /** + * Go to previous page + */ + async previousPage() { + if (this.state.currentPage > 1) { + await this.loadPrizes(this.state.currentPage - 1); + window.scrollTo({ top: 0, behavior: 'smooth' }); + } + } + + /** + * Go to first page + */ + async firstPage() { + if (this.state.currentPage !== 1) { + await this.loadPrizes(1); + window.scrollTo({ top: 0, behavior: 'smooth' }); + } + } + + /** + * Go to next page + */ + async nextPage() { + const totalPages = Math.ceil( + this.state.totalPrizes / this.state.itemsPerPage + ); + const normalizedTotalPages = Math.max(totalPages, 1); + if (this.state.currentPage < normalizedTotalPages) { + await this.loadPrizes(this.state.currentPage + 1); + window.scrollTo({ top: 0, behavior: 'smooth' }); + } + } + + /** + * Go to last page + */ + async lastPage() { + const totalPages = Math.ceil( + this.state.totalPrizes / this.state.itemsPerPage + ); + const normalizedTotalPages = Math.max(totalPages, 1); + if (this.state.currentPage < normalizedTotalPages) { + await this.loadPrizes(normalizedTotalPages); + window.scrollTo({ top: 0, behavior: 'smooth' }); + } + } + + /** + * Show loading indicator + */ + showLoading() { + this.dom.loading.classList.add('active'); + this.dom.errorMessage.classList.remove('active'); + } + + /** + * Hide loading indicator + */ + hideLoading() { + this.dom.loading.classList.remove('active'); + } + + /** + * Show error message + */ + showError(message) { + const errorElement = this.dom.errorMessage; + errorElement.textContent = message; + errorElement.classList.add('active'); + this.hideLoading(); + } +} diff --git a/tests/task1-a.test.js b/tests/task1-a.test.js new file mode 100644 index 0000000..e29c388 --- /dev/null +++ b/tests/task1-a.test.js @@ -0,0 +1,20 @@ +import { exec } from 'node:child_process'; +import { promisify } from 'node:util'; +import { describe, expect, test } from 'vitest'; + +const execAsync = promisify(exec); + +describe('Task 1 - Fetching Data with curl', () => { + test('should fetch data from the API using curl', async () => { + const { stdout, stderr } = await execAsync('bash task-1/task1-a.sh'); + if (stderr && !stderr.includes('% Total')) { + throw new Error(stderr); + } + + const data = JSON.parse(stdout); + expect(data).toHaveProperty('userId', 1); + expect(data).toHaveProperty('id', 1); + expect(data).toHaveProperty('title', 'delectus aut autem'); + expect(data).toHaveProperty('completed', false); + }); +}); diff --git a/tests/task1-b.test.js b/tests/task1-b.test.js new file mode 100644 index 0000000..14ca533 --- /dev/null +++ b/tests/task1-b.test.js @@ -0,0 +1,18 @@ +import { exec } from 'node:child_process'; +import { promisify } from 'node:util'; +import { describe, expect, test } from 'vitest'; + +const execAsync = promisify(exec); + +describe('Task 2 - Fetching Data with curl', () => { + test('should fetch data from the API using curl', async () => { + const { stdout, stderr } = await execAsync('bash task-1/task1-b.sh'); + if (stderr && !stderr.includes('% Total')) { + throw new Error(stderr); + } + + const data = JSON.parse(stdout); + console.log(data); + expect(data).toHaveProperty('commonName', 'Netherlands'); + }); +}); From 91e4e715b54997d68d951ffae2390654c86bea24 Mon Sep 17 00:00:00 2001 From: Tester Date: Tue, 3 Feb 2026 17:42:34 +0100 Subject: [PATCH 2/7] Add curl exercise --- .gitignore | 5 +- .hyf/task-1.sh | 39 + .vscode/settings.json | 8 +- README.md | 33 +- package-lock.json | 1450 +++++++++++++++++++++++++++++++++++++- package.json | 7 + task-1/GUIDE.md | 95 +++ task-1/db.json | 103 +++ task-1/server/server.js | 130 ++++ task-1/server/users.json | 114 +++ task-1/task1-a.sh | 3 - task-1/task1-b.sh | 4 - tests/task1-a.test.js | 20 - tests/task1-b.test.js | 18 - 14 files changed, 1974 insertions(+), 55 deletions(-) create mode 100644 .hyf/task-1.sh create mode 100644 task-1/GUIDE.md create mode 100644 task-1/db.json create mode 100644 task-1/server/server.js create mode 100644 task-1/server/users.json delete mode 100644 task-1/task1-a.sh delete mode 100644 task-1/task1-b.sh delete mode 100644 tests/task1-a.test.js delete mode 100644 tests/task1-b.test.js diff --git a/.gitignore b/.gitignore index ef0601d..4be3eb0 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ Thumbs.db .hyf/score.json # Editor and IDE settings -# Commit .vscode with settings to disable GitHub Copilot +# Commit .vscode with settings to disable GitHub Copilot inline suggestions # .vscode/ .idea/ *.iml @@ -158,3 +158,6 @@ vite.config.js.timestamp-* vite.config.ts.timestamp-* task-2/services-solution.js + +solutions/ +.hyf/temp \ No newline at end of file diff --git a/.hyf/task-1.sh b/.hyf/task-1.sh new file mode 100644 index 0000000..d65c69c --- /dev/null +++ b/.hyf/task-1.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +hyf_folder=$PWD +#target_folder="$PWD/../task-1" +target_folder="$PWD/../solutions/task-1" +temp_folder="$hyf_folder/temp" + +mkdir "$temp_folder" 2>/dev/null + +if [ ! -f "$target_folder/post.sh" ]; then + echo "post.sh not found!" + exit 1 +fi +if [ ! -f "$target_folder/patch.sh" ]; then + echo "patch.sh not found!" + exit 1 +fi +if [ ! -f "$target_folder/get.sh" ]; then + echo "get.sh not found!" + exit 1 +fi +if [ ! -f "$target_folder/delete.sh" ]; then + echo "delete.sh not found!" + exit 1 +fi + +cd .. +/usr/bin/env npm install +/usr/bin/env npm start & +sleep 3 + +cd "$target_folder" || exit + +bash post.sh >"$temp_folder/post.json" 2>/dev/null +bash patch.sh >"$temp_folder/patch.json" 2>/dev/null +bash get.sh >"$temp_folder/get.json" 2>/dev/null +bash delete.sh 2>/dev/null +bash get.sh >"$temp_folder/notfound.txt" 2>/dev/null +kill -9 $(lsof -t -i:3000) diff --git a/.vscode/settings.json b/.vscode/settings.json index 0c13e99..db90201 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { - "editor.inlineSuggest.enabled": false, - "github.copilot.enable": { - "javascript": false - } + // "editor.inlineSuggest.enabled": false + // "github.copilot.enable": { + // "javascript": false + // } } diff --git a/README.md b/README.md index df6e3ea..6a1d5e3 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,39 @@ # Core program week X assignment -HackYourFuture week X assignment + +Core Program week 9 assignment ## Implementation Instructions -Provide clear instructions on how trainees should implement the tasks. ### Task 1 -Instructions for Task 1 + +In this task you will practice reading API documentation and using `curl`. The API reference you need is in the [GUIDE.md](task-1/GUIDE.md) file. Read it carefully and construct your own `curl` requests from the endpoint details. + +Before you start, open a terminal in the repository root and start the server with `npm start`. Keep it running while you work. + +Create your scripts inside the `task-1` folder and run each script with `bash` after you finish it. If a command fails, compare your request to the examples in the [GUIDE](task-1/GUIDE.md). + +1. Create a `post.sh` bash script. It must send a POST request with `curl` to create a new user. Use these values in the JSON body: + + | Field | Value | + | ----- | ----- | + | name | John Doe | + | email | john.doe@example.com | + | role | user | + | active | true | + | department | Engineering | + + Run the script. Record the `id` in the response. You will use it in the next steps. + +2. The email address from the previous step mistakenly includes an extra dot between first and last name. We will correct it here. Create a `patch.sh` bash script. It must send a `curl` PATCH request to update only the email for the user you just created. Fix the email by removing the extra dot, changing it to `johndoe@example.com`. Note a PATCH request should include only the field you are updating, in our case this is the `email` field only. + +3. Create a `get.sh` script. It must send a `curl` GET request to fetch the user by `id`. Verify the response contains the updated email. + +4. Create `delete.sh` script. It must send a `curl` DELETE request for the same `id` to remove the user. + +5. Re-run the `get.sh` script. The response should now be `User not found`. ### Task 2 + Instructions for Task 2 ... - diff --git a/package-lock.json b/package-lock.json index 46593b2..cb7033f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,12 @@ "name": "core-assignment-week-10", "version": "1.0.0", "license": "ISC", + "dependencies": { + "bcrypt": "^6.0.0", + "express": "^5.2.1", + "json-server": "^1.0.0-beta.5", + "morgan": "^1.10.1" + }, "devDependencies": { "vitest": "^4.0.17" } @@ -461,6 +467,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@polka/url": { + "version": "1.0.0-next.29", + "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.29.tgz", + "integrity": "sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==", + "license": "MIT" + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.57.1", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.57.1.tgz", @@ -818,6 +830,242 @@ "dev": true, "license": "MIT" }, + "node_modules/@tinyhttp/accepts": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@tinyhttp/accepts/-/accepts-2.3.0.tgz", + "integrity": "sha512-hdKkMGAUqnagpWO1R8rVBYqbu4sWQ2Fo682gkJmO0nl54DPvnzxx81b2WZtV3VwB7EdLfUoasj2BAkyTcyZ5aw==", + "license": "MIT", + "dependencies": { + "mime": "4.1.0" + }, + "engines": { + "node": ">=14.13.1" + }, + "funding": { + "type": "individual", + "url": "https://github.com/tinyhttp/tinyhttp?sponsor=1" + } + }, + "node_modules/@tinyhttp/app": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@tinyhttp/app/-/app-3.0.4.tgz", + "integrity": "sha512-Zczj+eOMw2JI3/zW4rdJ0t+0hDkxpdWx0UOXAMhh94Yy2kjZtbXq3HdXH1iU8j1EaQlfNAM5UIqs+CZveQ9Tkw==", + "license": "MIT", + "dependencies": { + "@tinyhttp/cookie": "2.1.1", + "@tinyhttp/proxy-addr": "3.0.1", + "@tinyhttp/req": "2.2.7", + "@tinyhttp/res": "2.2.9", + "@tinyhttp/router": "2.2.3", + "header-range-parser": "1.1.3", + "regexparam": "^2.0.2" + }, + "engines": { + "node": ">=16.10.0" + }, + "funding": { + "type": "individual", + "url": "https://github.com/tinyhttp/tinyhttp?sponsor=1" + } + }, + "node_modules/@tinyhttp/content-disposition": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@tinyhttp/content-disposition/-/content-disposition-2.2.4.tgz", + "integrity": "sha512-5Kc5CM2Ysn3vTTArBs2vESUt0AQiWZA86yc1TI3B+lxXmtEq133C1nxXNOgnzhrivdPZIh3zLj5gDnZjoLL5GA==", + "license": "MIT", + "engines": { + "node": ">=12.17.0" + }, + "funding": { + "type": "individual", + "url": "https://github.com/tinyhttp/tinyhttp?sponsor=1" + } + }, + "node_modules/@tinyhttp/content-type": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/@tinyhttp/content-type/-/content-type-0.1.4.tgz", + "integrity": "sha512-dl6f3SHIJPYbhsW1oXdrqOmLSQF/Ctlv3JnNfXAE22kIP7FosqJHxkz/qj2gv465prG8ODKH5KEyhBkvwrueKQ==", + "license": "MIT", + "engines": { + "node": ">=12.4" + } + }, + "node_modules/@tinyhttp/cookie": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@tinyhttp/cookie/-/cookie-2.1.1.tgz", + "integrity": "sha512-h/kL9jY0e0Dvad+/QU3efKZww0aTvZJslaHj3JTPmIPC9Oan9+kYqmh3M6L5JUQRuTJYFK2nzgL2iJtH2S+6dA==", + "license": "MIT", + "engines": { + "node": ">=12.20.0" + }, + "funding": { + "type": "individual", + "url": "https://github.com/tinyhttp/tinyhttp?sponsor=1" + } + }, + "node_modules/@tinyhttp/cookie-signature": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@tinyhttp/cookie-signature/-/cookie-signature-2.1.1.tgz", + "integrity": "sha512-VDsSMY5OJfQJIAtUgeQYhqMPSZptehFSfvEEtxr+4nldPA8IImlp3QVcOVuK985g4AFR4Hl1sCbWCXoqBnVWnw==", + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/@tinyhttp/cors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@tinyhttp/cors/-/cors-2.0.1.tgz", + "integrity": "sha512-qrmo6WJuaiCzKWagv2yA/kw6hIISfF/hOqPWwmI6w0o8apeTMmRN3DoCFvQ/wNVuWVdU5J4KU7OX8aaSOEq51A==", + "license": "MIT", + "dependencies": { + "@tinyhttp/vary": "^0.1.3" + }, + "engines": { + "node": ">=12.20 || 14.x || >=16" + } + }, + "node_modules/@tinyhttp/encode-url": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@tinyhttp/encode-url/-/encode-url-2.1.1.tgz", + "integrity": "sha512-AhY+JqdZ56qV77tzrBm0qThXORbsVjs/IOPgGCS7x/wWnsa/Bx30zDUU/jPAUcSzNOzt860x9fhdGpzdqbUeUw==", + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/@tinyhttp/etag": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@tinyhttp/etag/-/etag-2.1.2.tgz", + "integrity": "sha512-j80fPKimGqdmMh6962y+BtQsnYPVCzZfJw0HXjyH70VaJBHLKGF+iYhcKqzI3yef6QBNa8DKIPsbEYpuwApXTw==", + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/@tinyhttp/forwarded": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@tinyhttp/forwarded/-/forwarded-2.1.2.tgz", + "integrity": "sha512-9H/eulJ68ElY/+zYpTpNhZ7vxGV+cnwaR6+oQSm7bVgZMyuQfgROW/qvZuhmgDTIxnGMXst+Ba4ij6w6Krcs3w==", + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/@tinyhttp/logger": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@tinyhttp/logger/-/logger-2.1.0.tgz", + "integrity": "sha512-Ma1fJ9CwUbn9r61/4HW6+nflsVoslpOnCrfQ6UeZq7GGIgwLzofms3HoSVG7M+AyRMJpxlfcDdbH5oFVroDMKA==", + "license": "MIT", + "dependencies": { + "colorette": "^2.0.20", + "dayjs": "^1.11.13", + "http-status-emojis": "^2.2.0" + }, + "engines": { + "node": ">=14.18 || >=16.20" + } + }, + "node_modules/@tinyhttp/proxy-addr": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@tinyhttp/proxy-addr/-/proxy-addr-3.0.1.tgz", + "integrity": "sha512-vP0JVsy9ZMIldsaP/QHdMF+sb3B6wn7e2QXRdqpX/Cqz1ie35Am29DK88DeVmiwdTQle3FtYaVNtU3RgTGYZ+w==", + "license": "MIT", + "dependencies": { + "@tinyhttp/forwarded": "2.1.2" + }, + "engines": { + "node": ">=16.10.0" + } + }, + "node_modules/@tinyhttp/req": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@tinyhttp/req/-/req-2.2.7.tgz", + "integrity": "sha512-B+tbfEogqz4FuP+V9yDYXErLedzdEKfBzvw4u6gsByFP/ToM4NjyBLGnLBQvU83C3rqDIlDivjDmwxTNIaBpDw==", + "license": "MIT", + "dependencies": { + "@tinyhttp/accepts": "2.3.0", + "@tinyhttp/type-is": "2.2.5", + "@tinyhttp/url": "2.1.1", + "header-range-parser": "^1.1.3" + }, + "engines": { + "node": ">=14.13.1" + } + }, + "node_modules/@tinyhttp/res": { + "version": "2.2.9", + "resolved": "https://registry.npmjs.org/@tinyhttp/res/-/res-2.2.9.tgz", + "integrity": "sha512-Lk5GqR4UyguRHh/5UzVlmrb9U/+pyjm4NzGOAzToJk+eP2V1pp1fNbHGTzXi4BzsrJU+Q/7gRctHyLMMyWSrNQ==", + "license": "MIT", + "dependencies": { + "@tinyhttp/content-disposition": "2.2.4", + "@tinyhttp/cookie": "2.1.1", + "@tinyhttp/cookie-signature": "2.1.1", + "@tinyhttp/encode-url": "2.1.1", + "@tinyhttp/req": "2.2.7", + "@tinyhttp/send": "2.2.4", + "@tinyhttp/vary": "^0.1.3", + "es-escape-html": "^0.1.1", + "mime": "4.1.0" + }, + "engines": { + "node": ">=14.13.1" + } + }, + "node_modules/@tinyhttp/router": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/@tinyhttp/router/-/router-2.2.3.tgz", + "integrity": "sha512-O0MQqWV3Vpg/uXsMYg19XsIgOhwjyhTYWh51Qng7bxqXixxx2PEvZWnFjP7c84K7kU/nUX41KpkEBTLnznk9/Q==", + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/@tinyhttp/send": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@tinyhttp/send/-/send-2.2.4.tgz", + "integrity": "sha512-DgEY185oQUd2LTKHM+he/m3sjYWB7yL0WLNrasoSEHaCfzstm0+viltqqOvEV7UtkSB3oRRo+OWiEtYKmd6h5w==", + "license": "MIT", + "dependencies": { + "@tinyhttp/content-type": "^0.1.4", + "@tinyhttp/etag": "2.1.2", + "mime": "4.1.0" + }, + "engines": { + "node": ">=14.13.1" + } + }, + "node_modules/@tinyhttp/type-is": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@tinyhttp/type-is/-/type-is-2.2.5.tgz", + "integrity": "sha512-BCPEB+NV8v/9lzEE9GbfRPAKVsyayp84m6SSWn70j8yFkPBXeuVeq004pwVrjW1CRdmAZz9ZSH147pqqzAdr5g==", + "license": "MIT", + "dependencies": { + "@tinyhttp/content-type": "^0.1.4", + "mime": "4.1.0" + }, + "engines": { + "node": ">=14.13.1" + } + }, + "node_modules/@tinyhttp/url": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@tinyhttp/url/-/url-2.1.1.tgz", + "integrity": "sha512-POJeq2GQ5jI7Zrdmj22JqOijB5/GeX+LEX7DUdml1hUnGbJOTWDx7zf2b5cCERj7RoXL67zTgyzVblBJC+NJWg==", + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/@tinyhttp/vary": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@tinyhttp/vary/-/vary-0.1.3.tgz", + "integrity": "sha512-SoL83sQXAGiHN1jm2VwLUWQSQeDAAl1ywOm6T0b0Cg1CZhVsjoiZadmjhxF6FHCCY7OHHVaLnTgSMxTPIDLxMg==", + "license": "MIT", + "engines": { + "node": ">=12.20" + } + }, "node_modules/@types/chai": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", @@ -954,6 +1202,19 @@ "url": "https://opencollective.com/vitest" } }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/assertion-error": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", @@ -964,6 +1225,94 @@ "node": ">=12" } }, + "node_modules/basic-auth": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", + "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.1.2" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/bcrypt": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-6.0.0.tgz", + "integrity": "sha512-cU8v/EGSrnH+HnxV2z0J7/blxH8gq7Xh2JFT6Aroax7UohdmiJJlxApMxtKfuI7z68NvvVcmR78k2LbT6efhRg==", + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "node-addon-api": "^8.3.0", + "node-gyp-build": "^4.8.4" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/body-parser": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz", + "integrity": "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.3", + "http-errors": "^2.0.0", + "iconv-lite": "^0.7.0", + "on-finished": "^2.4.1", + "qs": "^6.14.1", + "raw-body": "^3.0.1", + "type-is": "^2.0.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/chai": { "version": "6.2.2", "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz", @@ -974,6 +1323,182 @@ "node": ">=18" } }, + "node_modules/chalk": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", + "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chokidar": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz", + "integrity": "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==", + "license": "MIT", + "dependencies": { + "readdirp": "^5.0.0" + }, + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/colorette": { + "version": "2.0.20", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz", + "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", + "license": "MIT" + }, + "node_modules/content-disposition": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz", + "integrity": "sha512-oIXISMynqSqm241k6kcQ5UwttDILMK4BiurCfGEREw6+X9jkkpEe5T9FZaApyLGGOnFuyMWZpdolTXMtvEJ08Q==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/dayjs": { + "version": "1.11.19", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.19.tgz", + "integrity": "sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/dot-prop": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-10.1.0.tgz", + "integrity": "sha512-MVUtAugQMOff5RnBy2d9N31iG0lNwg1qAoAOn7pOK5wf94WIaE3My2p3uwTQuvS2AcqchkcR3bHByjaM0mmi7Q==", + "license": "MIT", + "dependencies": { + "type-fest": "^5.0.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-escape-html": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/es-escape-html/-/es-escape-html-0.1.1.tgz", + "integrity": "sha512-yUx1o+8RsG7UlszmYPtks+dm6Lho2m8lgHMOsLJQsFI0R8XwUJwiMhM1M4E/S8QLeGyf6MkDV/pWgjQ0tdTSyQ==", + "license": "MIT", + "engines": { + "node": ">=12.x" + } + }, "node_modules/es-module-lexer": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", @@ -981,6 +1506,18 @@ "dev": true, "license": "MIT" }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/esbuild": { "version": "0.27.2", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.2.tgz", @@ -1023,7 +1560,13 @@ "@esbuild/win32-x64": "0.27.2" } }, - "node_modules/estree-walker": { + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/estree-walker": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", @@ -1033,6 +1576,27 @@ "@types/estree": "^1.0.0" } }, + "node_modules/eta": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/eta/-/eta-4.5.0.tgz", + "integrity": "sha512-qifAYjuW5AM1eEEIsFnOwB+TGqu6ynU3OKj9WbUTOtUBHFPZqL03XUW34kbp3zm19Ald+U8dEyRXaVsUck+Y1g==", + "license": "MIT", + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/bgub/eta?sponsor=1" + } + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/expect-type": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.3.0.tgz", @@ -1043,6 +1607,49 @@ "node": ">=12.0.0" } }, + "node_modules/express": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", + "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.1", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/fdir": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", @@ -1061,6 +1668,45 @@ } } }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -1076,6 +1722,223 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/header-range-parser": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/header-range-parser/-/header-range-parser-1.1.3.tgz", + "integrity": "sha512-B9zCFt3jH8g09LR1vHL4pcAn8yMEtlSlOUdQemzHMRKMImNIhhszdeosYFfNW0WXKQtXIlWB+O4owHJKvEJYaA==", + "license": "MIT", + "engines": { + "node": ">=12.22.0" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/http-status-emojis": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/http-status-emojis/-/http-status-emojis-2.2.0.tgz", + "integrity": "sha512-ompKtgwpx8ff0hsbpIB7oE4ax1LXoHmftsHHStMELX56ivG3GhofTX8ZHWlUaFKfGjcGjw6G3rPk7dJRXMmbbg==", + "license": "MIT" + }, + "node_modules/iconv-lite": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz", + "integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/inflection": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/inflection/-/inflection-3.0.2.tgz", + "integrity": "sha512-+Bg3+kg+J6JUWn8J6bzFmOWkTQ6L/NHfDRSYU+EVvuKHDxUDHAXgqixHfVlzuBQaPOTac8hn43aPhMNk6rMe3g==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, + "node_modules/json-server": { + "version": "1.0.0-beta.5", + "resolved": "https://registry.npmjs.org/json-server/-/json-server-1.0.0-beta.5.tgz", + "integrity": "sha512-CvoacHWudRGAlCSnX359W4zTcRSM3FQte2s5rXvWb1R+msDsJNx8AOErFXXmzY6mg3vE5YKJUyFbyUd3YGkiRQ==", + "license": "SEE LICENSE IN ./LICENSE", + "dependencies": { + "@tinyhttp/app": "^3.0.1", + "@tinyhttp/cors": "^2.0.1", + "@tinyhttp/logger": "^2.1.0", + "chalk": "^5.6.2", + "chokidar": "^5.0.0", + "dot-prop": "^10.1.0", + "eta": "^4.5.0", + "inflection": "^3.0.2", + "json5": "^2.2.3", + "lowdb": "^7.0.1", + "milliparsec": "^5.1.0", + "sirv": "^3.0.2", + "sort-on": "^7.0.0" + }, + "bin": { + "json-server": "lib/bin.js" + }, + "engines": { + "node": ">=22.12.0" + } + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/lowdb": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/lowdb/-/lowdb-7.0.1.tgz", + "integrity": "sha512-neJAj8GwF0e8EpycYIDFqEPcx9Qz4GUho20jWFR7YiFeXzF1YMLdxB36PypcTSPMA+4+LvgyMacYhlr18Zlymw==", + "license": "MIT", + "dependencies": { + "steno": "^4.0.2" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/magic-string": { "version": "0.30.21", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", @@ -1086,6 +1949,143 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/milliparsec": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/milliparsec/-/milliparsec-5.1.0.tgz", + "integrity": "sha512-/xFIv79W7RhnnRLcQOlNpm0xO5FrodBdWFIysI4jIimqCCOnYwBekh6p+Qx61MVooewwBI7WEanFYeo8KtR2dA==", + "license": "MIT", + "engines": { + "node": ">=18.13 || >=19.20 || >=20" + } + }, + "node_modules/mime": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-4.1.0.tgz", + "integrity": "sha512-X5ju04+cAzsojXKes0B/S4tcYtFAJ6tTMuSPBEn9CPGlrWr8Fiw7qYeLT0XyH80HSoAoqWCaz+MWKh22P7G1cw==", + "funding": [ + "https://github.com/sponsors/broofa" + ], + "license": "MIT", + "bin": { + "mime": "bin/cli.js" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/morgan": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.1.tgz", + "integrity": "sha512-223dMRJtI/l25dJKWpgij2cMtywuG/WiUKXdvwfbhGKBhy1puASqXwFzmWZ7+K73vUPoR7SS2Qz2cI/g9MKw0A==", + "license": "MIT", + "dependencies": { + "basic-auth": "~2.0.1", + "debug": "2.6.9", + "depd": "~2.0.0", + "on-finished": "~2.3.0", + "on-headers": "~1.1.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/morgan/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/morgan/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/morgan/node_modules/on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/mrmime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz", + "integrity": "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, "node_modules/nanoid": { "version": "3.3.11", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", @@ -1105,6 +2105,47 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-addon-api": { + "version": "8.5.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.5.0.tgz", + "integrity": "sha512-/bRZty2mXUIFY/xU5HLvveNHlswNJej+RnxBjOMkidWfwZzgTbPG1E3K5TOxRLOR+5hX7bSofy8yf1hZevMS8A==", + "license": "MIT", + "engines": { + "node": "^18 || ^20 || >= 21" + } + }, + "node_modules/node-gyp-build": { + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.4.tgz", + "integrity": "sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==", + "license": "MIT", + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/obug": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.1.tgz", @@ -1116,6 +2157,55 @@ ], "license": "MIT" }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/on-headers": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.1.0.tgz", + "integrity": "sha512-737ZY3yNnXy37FHkQxPzt4UZ2UWPWiCZWLvFZ4fu5cueciegX0zGPnrlY6bwRg4FdQOe9YU8MkmJwGhoMybl8A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz", + "integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/pathe": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", @@ -1173,6 +2263,80 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.14.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz", + "integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/readdirp": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.0.0.tgz", + "integrity": "sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ==", + "license": "MIT", + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/regexparam": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/regexparam/-/regexparam-2.0.2.tgz", + "integrity": "sha512-A1PeDEYMrkLrfyOwv2jwihXbo9qxdGD3atBYQA9JJgreAx8/7rC6IUkWOw2NQlOxLp2wL0ifQbh1HuidDfYA6w==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/rollup": { "version": "4.57.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.57.1.tgz", @@ -1218,6 +2382,157 @@ "fsevents": "~2.3.2" } }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/serve-static": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", + "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/siginfo": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", @@ -1225,6 +2540,35 @@ "dev": true, "license": "ISC" }, + "node_modules/sirv": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.2.tgz", + "integrity": "sha512-2wcC/oGxHis/BoHkkPwldgiPSYcpZK3JU28WoMVv55yHJgcZ8rlXvuG9iZggz+sU1d4bRgIGASwyWqjxu3FM0g==", + "license": "MIT", + "dependencies": { + "@polka/url": "^1.0.0-next.24", + "mrmime": "^2.0.0", + "totalist": "^3.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/sort-on": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/sort-on/-/sort-on-7.0.0.tgz", + "integrity": "sha512-e+4RRxt7jsWdGPp4H5PKOER/ELYlemNB1plvW686Qi3j4WVaCjCpro2zaTD7Cn0VtBImq/hg3x1JfovMNXXfJQ==", + "license": "MIT", + "dependencies": { + "dot-prop": "^10.1.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -1242,6 +2586,15 @@ "dev": true, "license": "MIT" }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/std-env": { "version": "3.10.0", "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz", @@ -1249,6 +2602,30 @@ "dev": true, "license": "MIT" }, + "node_modules/steno": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/steno/-/steno-4.0.2.tgz", + "integrity": "sha512-yhPIQXjrlt1xv7dyPQg2P17URmXbuM5pdGkpiMB3RenprfiBlvK415Lctfe0eshk90oA7/tNq7WEiMK8RSP39A==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, + "node_modules/tagged-tag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/tagged-tag/-/tagged-tag-1.0.0.tgz", + "integrity": "sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng==", + "license": "MIT", + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/tinybench": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", @@ -1293,6 +2670,71 @@ "node": ">=14.0.0" } }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/type-fest": { + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-5.4.3.tgz", + "integrity": "sha512-AXSAQJu79WGc79/3e9/CR77I/KQgeY1AhNvcShIH4PTcGYyC4xv6H4R4AUOwkPS5799KlVDAu8zExeCrkGquiA==", + "license": "(MIT OR CC0-1.0)", + "dependencies": { + "tagged-tag": "^1.0.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/type-is": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", + "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "license": "MIT", + "dependencies": { + "content-type": "^1.0.5", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/vite": { "version": "7.3.1", "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.1.tgz", @@ -1463,6 +2905,12 @@ "engines": { "node": ">=8" } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" } } } diff --git a/package.json b/package.json index 197c991..e5fe94d 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "", "main": "index.js", "scripts": { + "start": "node task-1/server/server.js", "test": "vitest" }, "keywords": [], @@ -12,5 +13,11 @@ "type": "module", "devDependencies": { "vitest": "^4.0.17" + }, + "dependencies": { + "bcrypt": "^6.0.0", + "express": "^5.2.1", + "json-server": "^1.0.0-beta.5", + "morgan": "^1.10.1" } } diff --git a/task-1/GUIDE.md b/task-1/GUIDE.md new file mode 100644 index 0000000..2c9f24d --- /dev/null +++ b/task-1/GUIDE.md @@ -0,0 +1,95 @@ +# Users API — Usage Guide + +This guide describes the users API backed by the local users.json file. It explains the endpoints, required data, and expected behavior so you can build your own requests. + +Base URL: + +All requests that send a body must use JSON and include the header: + +- Content-Type: application/json; charset=UTF-8 + +## Get a single user + +- Method: GET +- Path: /users/:id +- Path parameter: `id` (number) + +Response: a single user object (without `password`) or the text `User not found`. + +## List all users + +- Method: GET +- Path: /users + +Response: an array of users (without `password`). + +## Create a user + +- Method: POST +- Path: /users +- Body: JSON with the following fields: + + - `name` (string) + - `email` (string) + - `password` (string, required) + - `role` (string) + - `active` (boolean) + - `department` (string) + +Example body: + + { + "name": "Jane Smith", + "email": "jane.smith@example.com", + "password": "secret123", + "role": "user", + "active": true, + "department": "Engineering" + } + +Response: the created user (without `password`) and a generated `id`. + +## Update a user (replace all fields) + +- Method: PUT +- Path: /users/:id +- Body: JSON with the full user object (all fields you want to keep must be included). + +Example body: + + { + "name": "Alice Johnson", + "email": "alice.johnson@example.com", + "password": "new-secret", + "role": "admin", + "active": true, + "department": "Engineering" + } + +Response: the updated user (without `password`). + +## Patch a user (partial update) + +- Method: PATCH +- Path: /users/:id +- Body: JSON with only the fields you want to change. + +Example body: + + { + "email": "alice.updated@example.com" + } + +Response: the updated user (without `password`). + +## Delete a user + +- Method: DELETE +- Path: /users/:id + +Response: no content on success. + +## Notes + +- Passwords are never returned in API responses. +- The server hashes the `password` you send in POST, PUT, or PATCH requests. diff --git a/task-1/db.json b/task-1/db.json new file mode 100644 index 0000000..8a8bd08 --- /dev/null +++ b/task-1/db.json @@ -0,0 +1,103 @@ +{ + "users": [ + { + "id": "a1b2", + "name": "Alice Johnson", + "email": "alice.johnson@example.com", + "password": "$2b$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "admin", + "active": true, + "department": "Engineering" + }, + { + "id": "c3d4", + "name": "Bob Smith", + "email": "bob.smith@example.com", + "password": "$2b$10$V8qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "user", + "active": true, + "department": "Marketing" + }, + { + "id": "e5f6", + "name": "Carol Williams", + "email": "carol.williams@example.com", + "password": "$2b$10$X7qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "moderator", + "active": true, + "department": "Content" + }, + { + "id": "a7b8", + "name": "David Brown", + "email": "david.brown@example.com", + "password": "$2b$10$Y6qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "user", + "active": false, + "department": "Sales" + }, + { + "id": "c9d0", + "name": "Emma Davis", + "email": "emma.davis@example.com", + "password": "$2b$10$Z5qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "admin", + "active": true, + "department": "Engineering" + }, + { + "id": "e1f2", + "name": "Frank Miller", + "email": "frank.miller@example.com", + "password": "$2b$10$A4qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "user", + "active": true, + "department": "HR" + }, + { + "id": "a3b4", + "name": "Grace Lee", + "email": "grace.lee@example.com", + "password": "$2b$10$B3qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "moderator", + "active": true, + "department": "Content" + }, + { + "id": "c5d6", + "name": "Henry Taylor", + "email": "henry.taylor@example.com", + "password": "$2b$10$C2qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "user", + "active": false, + "department": "Finance" + }, + { + "id": "e7f8", + "name": "Iris Anderson", + "email": "iris.anderson@example.com", + "password": "$2b$10$D1qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "user", + "active": true, + "department": "Marketing" + }, + { + "id": "a9b0", + "name": "Jack Wilson", + "email": "jack.wilson@example.com", + "password": "$2b$10$E0qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "moderator", + "active": true, + "department": "Engineering" + }, + { + "id": "6f04", + "name": "John Doe", + "email": "john.doe@example.com", + "password": "12345678", + "role": "user", + "active": true, + "department": "Engineering" + } + ] +} \ No newline at end of file diff --git a/task-1/server/server.js b/task-1/server/server.js new file mode 100644 index 0000000..3c301c3 --- /dev/null +++ b/task-1/server/server.js @@ -0,0 +1,130 @@ +import bcrypt from 'bcrypt'; +import express from 'express'; +import fs from 'fs'; +import morgan from 'morgan'; +import { dirname, join } from 'path'; +import { fileURLToPath } from 'url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const app = express(); +const PORT = 3000; +const usersFilePath = join(__dirname, 'users.json'); + +// app.use(morgan('dev')); +app.use(express.json()); + +// Helper function to read users from the JSON file +const readUsers = () => { + const data = fs.readFileSync(usersFilePath); + return JSON.parse(data).users; +}; + +// Helper function to write users to the JSON file +const writeUsers = (users) => { + fs.writeFileSync(usersFilePath, JSON.stringify({ users }, null, 2)); +}; + +// GET all users +app.get('/users', (req, res) => { + const users = readUsers().map(({ password, ...user }) => user); // Exclude password + res.json(users); +}); + +// GET a user by ID +app.get('/users/:id', (req, res) => { + const users = readUsers(); + const user = users.find(u => u.id === parseInt(req.params.id)); + if (user) { + const { password, ...userWithoutPassword } = user; // Exclude password + res.json(userWithoutPassword); + } else { + res.status(404).send('User not found'); + } +}); + +// CREATE a new user +app.post('/users', async (req, res) => { + const { name, email, password, role, department } = req.body; + const hashedPassword = await bcrypt.hash(password, 10); + const users = readUsers(); + const newUser = { + id: users.length + 1, + name, + email, + password: hashedPassword, + role, + active: true, + createdAt: new Date().toISOString(), + lastLogin: null, + department + }; + users.push(newUser); + writeUsers(users); + const { password: _, ...userWithoutPassword } = newUser; + res.status(201).json(userWithoutPassword); +}); + +// UPDATE a user by ID +app.put('/users/:id', async (req, res) => { + const users = readUsers(); + const userIndex = users.findIndex(u => u.id === parseInt(req.params.id)); + if (userIndex !== -1) { + const { name, email, password, role, department } = req.body; + const updatedUser = { + ...users[userIndex], + name, + email, + role, + department, + ...(password && { password: await bcrypt.hash(password, 10) }) // Update password if provided + }; + users[userIndex] = updatedUser; + writeUsers(users); + const { password: _, ...userWithoutPassword } = updatedUser; + res.json(userWithoutPassword); + } else { + res.status(404).send('User not found'); + } +}); + +// PATCH a user by ID (partial update) +app.patch('/users/:id', async (req, res) => { + const users = readUsers(); + const userIndex = users.findIndex(u => u.id === parseInt(req.params.id)); + if (userIndex !== -1) { + const updates = { ...req.body }; + // If password is provided, hash it + if (updates.password) { + updates.password = await bcrypt.hash(updates.password, 10); + } + const updatedUser = { + ...users[userIndex], + ...updates + }; + users[userIndex] = updatedUser; + writeUsers(users); + const { password: _, ...userWithoutPassword } = updatedUser; + res.json(userWithoutPassword); + } else { + res.status(404).send('User not found'); + } +}); + +// DELETE a user by ID +app.delete('/users/:id', (req, res) => { + const users = readUsers(); + const userIndex = users.findIndex(u => u.id === parseInt(req.params.id)); + if (userIndex !== -1) { + users.splice(userIndex, 1); + writeUsers(users); + res.status(204).send(); + } else { + res.status(404).send('User not found'); + } +}); + +app.listen(PORT, () => { + console.log(`Server is running on http://localhost:${PORT}`); +}); \ No newline at end of file diff --git a/task-1/server/users.json b/task-1/server/users.json new file mode 100644 index 0000000..fc8d197 --- /dev/null +++ b/task-1/server/users.json @@ -0,0 +1,114 @@ +{ + "users": [ + { + "id": 1, + "name": "Alice Johnson", + "email": "alice.johnson@example.com", + "password": "$2b$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "admin", + "active": true, + "createdAt": "2024-01-15T08:30:00Z", + "lastLogin": "2026-02-03T10:45:00Z", + "department": "Engineering" + }, + { + "id": 2, + "name": "Bob Smith", + "email": "bob.smith@example.com", + "password": "$2b$10$V8qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "user", + "active": true, + "createdAt": "2024-02-20T09:15:00Z", + "lastLogin": "2026-02-02T14:22:00Z", + "department": "Marketing" + }, + { + "id": 3, + "name": "Carol Williams", + "email": "carol.williams@example.com", + "password": "$2b$10$X7qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "moderator", + "active": true, + "createdAt": "2024-03-10T11:00:00Z", + "lastLogin": "2026-02-01T09:30:00Z", + "department": "Content" + }, + { + "id": 4, + "name": "David Brown", + "email": "david.brown@example.com", + "password": "$2b$10$Y6qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "user", + "active": false, + "createdAt": "2024-04-05T13:45:00Z", + "lastLogin": "2025-11-28T16:20:00Z", + "department": "Sales" + }, + { + "id": 5, + "name": "Emma Davis", + "email": "emma.davis@example.com", + "password": "$2b$10$Z5qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "admin", + "active": true, + "createdAt": "2024-01-08T07:20:00Z", + "lastLogin": "2026-02-03T08:15:00Z", + "department": "Engineering" + }, + { + "id": 6, + "name": "Frank Miller", + "email": "frank.miller@example.com", + "password": "$2b$10$A4qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "user", + "active": true, + "createdAt": "2024-05-12T10:30:00Z", + "lastLogin": "2026-01-31T12:00:00Z", + "department": "HR" + }, + { + "id": 7, + "name": "Grace Lee", + "email": "grace.lee@example.com", + "password": "$2b$10$B3qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "moderator", + "active": true, + "createdAt": "2024-06-18T14:15:00Z", + "lastLogin": "2026-02-02T15:45:00Z", + "department": "Content" + }, + { + "id": 8, + "name": "Henry Taylor", + "email": "henry.taylor@example.com", + "password": "$2b$10$C2qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "user", + "active": false, + "createdAt": "2024-07-22T16:00:00Z", + "lastLogin": "2025-12-15T11:30:00Z", + "department": "Finance" + }, + { + "id": 9, + "name": "Iris Anderson", + "email": "iris.anderson@example.com", + "password": "$2b$10$D1qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "user", + "active": true, + "createdAt": "2024-08-05T09:45:00Z", + "lastLogin": "2026-02-03T11:20:00Z", + "department": "Marketing" + }, + { + "id": 10, + "name": "Jack Wilson", + "email": "jack.wilson@example.com", + "password": "$2b$10$E0qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "moderator", + "active": true, + "createdAt": "2024-09-14T12:30:00Z", + "lastLogin": "2026-02-03T13:00:00Z", + "department": "Engineering" + } + ] +} \ No newline at end of file diff --git a/task-1/task1-a.sh b/task-1/task1-a.sh deleted file mode 100644 index c948e5d..0000000 --- a/task-1/task1-a.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -curl https://jsonplaceholder.typicode.com/todos/1 diff --git a/task-1/task1-b.sh b/task-1/task1-b.sh deleted file mode 100644 index b184949..0000000 --- a/task-1/task1-b.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -curl https://date.nager.at/api/v3/CountryInfo/nl \ - --header 'Accept: */*' diff --git a/tests/task1-a.test.js b/tests/task1-a.test.js deleted file mode 100644 index e29c388..0000000 --- a/tests/task1-a.test.js +++ /dev/null @@ -1,20 +0,0 @@ -import { exec } from 'node:child_process'; -import { promisify } from 'node:util'; -import { describe, expect, test } from 'vitest'; - -const execAsync = promisify(exec); - -describe('Task 1 - Fetching Data with curl', () => { - test('should fetch data from the API using curl', async () => { - const { stdout, stderr } = await execAsync('bash task-1/task1-a.sh'); - if (stderr && !stderr.includes('% Total')) { - throw new Error(stderr); - } - - const data = JSON.parse(stdout); - expect(data).toHaveProperty('userId', 1); - expect(data).toHaveProperty('id', 1); - expect(data).toHaveProperty('title', 'delectus aut autem'); - expect(data).toHaveProperty('completed', false); - }); -}); diff --git a/tests/task1-b.test.js b/tests/task1-b.test.js deleted file mode 100644 index 14ca533..0000000 --- a/tests/task1-b.test.js +++ /dev/null @@ -1,18 +0,0 @@ -import { exec } from 'node:child_process'; -import { promisify } from 'node:util'; -import { describe, expect, test } from 'vitest'; - -const execAsync = promisify(exec); - -describe('Task 2 - Fetching Data with curl', () => { - test('should fetch data from the API using curl', async () => { - const { stdout, stderr } = await execAsync('bash task-1/task1-b.sh'); - if (stderr && !stderr.includes('% Total')) { - throw new Error(stderr); - } - - const data = JSON.parse(stdout); - console.log(data); - expect(data).toHaveProperty('commonName', 'Netherlands'); - }); -}); From a57e36702a8a1b2c6428ad8c5530e5f56ed997d1 Mon Sep 17 00:00:00 2001 From: Jim Cramer Date: Tue, 3 Feb 2026 19:28:38 +0100 Subject: [PATCH 3/7] No longer using json-server --- package-lock.json | 528 ---------------------------------------------- package.json | 1 - 2 files changed, 529 deletions(-) diff --git a/package-lock.json b/package-lock.json index cb7033f..ac3bca3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,6 @@ "dependencies": { "bcrypt": "^6.0.0", "express": "^5.2.1", - "json-server": "^1.0.0-beta.5", "morgan": "^1.10.1" }, "devDependencies": { @@ -467,12 +466,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@polka/url": { - "version": "1.0.0-next.29", - "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.29.tgz", - "integrity": "sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==", - "license": "MIT" - }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.57.1", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.57.1.tgz", @@ -830,242 +823,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@tinyhttp/accepts": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@tinyhttp/accepts/-/accepts-2.3.0.tgz", - "integrity": "sha512-hdKkMGAUqnagpWO1R8rVBYqbu4sWQ2Fo682gkJmO0nl54DPvnzxx81b2WZtV3VwB7EdLfUoasj2BAkyTcyZ5aw==", - "license": "MIT", - "dependencies": { - "mime": "4.1.0" - }, - "engines": { - "node": ">=14.13.1" - }, - "funding": { - "type": "individual", - "url": "https://github.com/tinyhttp/tinyhttp?sponsor=1" - } - }, - "node_modules/@tinyhttp/app": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@tinyhttp/app/-/app-3.0.4.tgz", - "integrity": "sha512-Zczj+eOMw2JI3/zW4rdJ0t+0hDkxpdWx0UOXAMhh94Yy2kjZtbXq3HdXH1iU8j1EaQlfNAM5UIqs+CZveQ9Tkw==", - "license": "MIT", - "dependencies": { - "@tinyhttp/cookie": "2.1.1", - "@tinyhttp/proxy-addr": "3.0.1", - "@tinyhttp/req": "2.2.7", - "@tinyhttp/res": "2.2.9", - "@tinyhttp/router": "2.2.3", - "header-range-parser": "1.1.3", - "regexparam": "^2.0.2" - }, - "engines": { - "node": ">=16.10.0" - }, - "funding": { - "type": "individual", - "url": "https://github.com/tinyhttp/tinyhttp?sponsor=1" - } - }, - "node_modules/@tinyhttp/content-disposition": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@tinyhttp/content-disposition/-/content-disposition-2.2.4.tgz", - "integrity": "sha512-5Kc5CM2Ysn3vTTArBs2vESUt0AQiWZA86yc1TI3B+lxXmtEq133C1nxXNOgnzhrivdPZIh3zLj5gDnZjoLL5GA==", - "license": "MIT", - "engines": { - "node": ">=12.17.0" - }, - "funding": { - "type": "individual", - "url": "https://github.com/tinyhttp/tinyhttp?sponsor=1" - } - }, - "node_modules/@tinyhttp/content-type": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/@tinyhttp/content-type/-/content-type-0.1.4.tgz", - "integrity": "sha512-dl6f3SHIJPYbhsW1oXdrqOmLSQF/Ctlv3JnNfXAE22kIP7FosqJHxkz/qj2gv465prG8ODKH5KEyhBkvwrueKQ==", - "license": "MIT", - "engines": { - "node": ">=12.4" - } - }, - "node_modules/@tinyhttp/cookie": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@tinyhttp/cookie/-/cookie-2.1.1.tgz", - "integrity": "sha512-h/kL9jY0e0Dvad+/QU3efKZww0aTvZJslaHj3JTPmIPC9Oan9+kYqmh3M6L5JUQRuTJYFK2nzgL2iJtH2S+6dA==", - "license": "MIT", - "engines": { - "node": ">=12.20.0" - }, - "funding": { - "type": "individual", - "url": "https://github.com/tinyhttp/tinyhttp?sponsor=1" - } - }, - "node_modules/@tinyhttp/cookie-signature": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@tinyhttp/cookie-signature/-/cookie-signature-2.1.1.tgz", - "integrity": "sha512-VDsSMY5OJfQJIAtUgeQYhqMPSZptehFSfvEEtxr+4nldPA8IImlp3QVcOVuK985g4AFR4Hl1sCbWCXoqBnVWnw==", - "license": "MIT", - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/cors": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@tinyhttp/cors/-/cors-2.0.1.tgz", - "integrity": "sha512-qrmo6WJuaiCzKWagv2yA/kw6hIISfF/hOqPWwmI6w0o8apeTMmRN3DoCFvQ/wNVuWVdU5J4KU7OX8aaSOEq51A==", - "license": "MIT", - "dependencies": { - "@tinyhttp/vary": "^0.1.3" - }, - "engines": { - "node": ">=12.20 || 14.x || >=16" - } - }, - "node_modules/@tinyhttp/encode-url": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@tinyhttp/encode-url/-/encode-url-2.1.1.tgz", - "integrity": "sha512-AhY+JqdZ56qV77tzrBm0qThXORbsVjs/IOPgGCS7x/wWnsa/Bx30zDUU/jPAUcSzNOzt860x9fhdGpzdqbUeUw==", - "license": "MIT", - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/etag": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@tinyhttp/etag/-/etag-2.1.2.tgz", - "integrity": "sha512-j80fPKimGqdmMh6962y+BtQsnYPVCzZfJw0HXjyH70VaJBHLKGF+iYhcKqzI3yef6QBNa8DKIPsbEYpuwApXTw==", - "license": "MIT", - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/forwarded": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@tinyhttp/forwarded/-/forwarded-2.1.2.tgz", - "integrity": "sha512-9H/eulJ68ElY/+zYpTpNhZ7vxGV+cnwaR6+oQSm7bVgZMyuQfgROW/qvZuhmgDTIxnGMXst+Ba4ij6w6Krcs3w==", - "license": "MIT", - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/logger": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@tinyhttp/logger/-/logger-2.1.0.tgz", - "integrity": "sha512-Ma1fJ9CwUbn9r61/4HW6+nflsVoslpOnCrfQ6UeZq7GGIgwLzofms3HoSVG7M+AyRMJpxlfcDdbH5oFVroDMKA==", - "license": "MIT", - "dependencies": { - "colorette": "^2.0.20", - "dayjs": "^1.11.13", - "http-status-emojis": "^2.2.0" - }, - "engines": { - "node": ">=14.18 || >=16.20" - } - }, - "node_modules/@tinyhttp/proxy-addr": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@tinyhttp/proxy-addr/-/proxy-addr-3.0.1.tgz", - "integrity": "sha512-vP0JVsy9ZMIldsaP/QHdMF+sb3B6wn7e2QXRdqpX/Cqz1ie35Am29DK88DeVmiwdTQle3FtYaVNtU3RgTGYZ+w==", - "license": "MIT", - "dependencies": { - "@tinyhttp/forwarded": "2.1.2" - }, - "engines": { - "node": ">=16.10.0" - } - }, - "node_modules/@tinyhttp/req": { - "version": "2.2.7", - "resolved": "https://registry.npmjs.org/@tinyhttp/req/-/req-2.2.7.tgz", - "integrity": "sha512-B+tbfEogqz4FuP+V9yDYXErLedzdEKfBzvw4u6gsByFP/ToM4NjyBLGnLBQvU83C3rqDIlDivjDmwxTNIaBpDw==", - "license": "MIT", - "dependencies": { - "@tinyhttp/accepts": "2.3.0", - "@tinyhttp/type-is": "2.2.5", - "@tinyhttp/url": "2.1.1", - "header-range-parser": "^1.1.3" - }, - "engines": { - "node": ">=14.13.1" - } - }, - "node_modules/@tinyhttp/res": { - "version": "2.2.9", - "resolved": "https://registry.npmjs.org/@tinyhttp/res/-/res-2.2.9.tgz", - "integrity": "sha512-Lk5GqR4UyguRHh/5UzVlmrb9U/+pyjm4NzGOAzToJk+eP2V1pp1fNbHGTzXi4BzsrJU+Q/7gRctHyLMMyWSrNQ==", - "license": "MIT", - "dependencies": { - "@tinyhttp/content-disposition": "2.2.4", - "@tinyhttp/cookie": "2.1.1", - "@tinyhttp/cookie-signature": "2.1.1", - "@tinyhttp/encode-url": "2.1.1", - "@tinyhttp/req": "2.2.7", - "@tinyhttp/send": "2.2.4", - "@tinyhttp/vary": "^0.1.3", - "es-escape-html": "^0.1.1", - "mime": "4.1.0" - }, - "engines": { - "node": ">=14.13.1" - } - }, - "node_modules/@tinyhttp/router": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/@tinyhttp/router/-/router-2.2.3.tgz", - "integrity": "sha512-O0MQqWV3Vpg/uXsMYg19XsIgOhwjyhTYWh51Qng7bxqXixxx2PEvZWnFjP7c84K7kU/nUX41KpkEBTLnznk9/Q==", - "license": "MIT", - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/send": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@tinyhttp/send/-/send-2.2.4.tgz", - "integrity": "sha512-DgEY185oQUd2LTKHM+he/m3sjYWB7yL0WLNrasoSEHaCfzstm0+viltqqOvEV7UtkSB3oRRo+OWiEtYKmd6h5w==", - "license": "MIT", - "dependencies": { - "@tinyhttp/content-type": "^0.1.4", - "@tinyhttp/etag": "2.1.2", - "mime": "4.1.0" - }, - "engines": { - "node": ">=14.13.1" - } - }, - "node_modules/@tinyhttp/type-is": { - "version": "2.2.5", - "resolved": "https://registry.npmjs.org/@tinyhttp/type-is/-/type-is-2.2.5.tgz", - "integrity": "sha512-BCPEB+NV8v/9lzEE9GbfRPAKVsyayp84m6SSWn70j8yFkPBXeuVeq004pwVrjW1CRdmAZz9ZSH147pqqzAdr5g==", - "license": "MIT", - "dependencies": { - "@tinyhttp/content-type": "^0.1.4", - "mime": "4.1.0" - }, - "engines": { - "node": ">=14.13.1" - } - }, - "node_modules/@tinyhttp/url": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@tinyhttp/url/-/url-2.1.1.tgz", - "integrity": "sha512-POJeq2GQ5jI7Zrdmj22JqOijB5/GeX+LEX7DUdml1hUnGbJOTWDx7zf2b5cCERj7RoXL67zTgyzVblBJC+NJWg==", - "license": "MIT", - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/vary": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@tinyhttp/vary/-/vary-0.1.3.tgz", - "integrity": "sha512-SoL83sQXAGiHN1jm2VwLUWQSQeDAAl1ywOm6T0b0Cg1CZhVsjoiZadmjhxF6FHCCY7OHHVaLnTgSMxTPIDLxMg==", - "license": "MIT", - "engines": { - "node": ">=12.20" - } - }, "node_modules/@types/chai": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", @@ -1323,39 +1080,6 @@ "node": ">=18" } }, - "node_modules/chalk": { - "version": "5.6.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", - "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", - "license": "MIT", - "engines": { - "node": "^12.17.0 || ^14.13 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/chokidar": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz", - "integrity": "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==", - "license": "MIT", - "dependencies": { - "readdirp": "^5.0.0" - }, - "engines": { - "node": ">= 20.19.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/colorette": { - "version": "2.0.20", - "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz", - "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", - "license": "MIT" - }, "node_modules/content-disposition": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz", @@ -1396,12 +1120,6 @@ "node": ">=6.6.0" } }, - "node_modules/dayjs": { - "version": "1.11.19", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.19.tgz", - "integrity": "sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==", - "license": "MIT" - }, "node_modules/debug": { "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", @@ -1428,21 +1146,6 @@ "node": ">= 0.8" } }, - "node_modules/dot-prop": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-10.1.0.tgz", - "integrity": "sha512-MVUtAugQMOff5RnBy2d9N31iG0lNwg1qAoAOn7pOK5wf94WIaE3My2p3uwTQuvS2AcqchkcR3bHByjaM0mmi7Q==", - "license": "MIT", - "dependencies": { - "type-fest": "^5.0.0" - }, - "engines": { - "node": ">=20" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", @@ -1490,15 +1193,6 @@ "node": ">= 0.4" } }, - "node_modules/es-escape-html": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/es-escape-html/-/es-escape-html-0.1.1.tgz", - "integrity": "sha512-yUx1o+8RsG7UlszmYPtks+dm6Lho2m8lgHMOsLJQsFI0R8XwUJwiMhM1M4E/S8QLeGyf6MkDV/pWgjQ0tdTSyQ==", - "license": "MIT", - "engines": { - "node": ">=12.x" - } - }, "node_modules/es-module-lexer": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", @@ -1576,18 +1270,6 @@ "@types/estree": "^1.0.0" } }, - "node_modules/eta": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/eta/-/eta-4.5.0.tgz", - "integrity": "sha512-qifAYjuW5AM1eEEIsFnOwB+TGqu6ynU3OKj9WbUTOtUBHFPZqL03XUW34kbp3zm19Ald+U8dEyRXaVsUck+Y1g==", - "license": "MIT", - "engines": { - "node": ">=20" - }, - "funding": { - "url": "https://github.com/bgub/eta?sponsor=1" - } - }, "node_modules/etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", @@ -1804,15 +1486,6 @@ "node": ">= 0.4" } }, - "node_modules/header-range-parser": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/header-range-parser/-/header-range-parser-1.1.3.tgz", - "integrity": "sha512-B9zCFt3jH8g09LR1vHL4pcAn8yMEtlSlOUdQemzHMRKMImNIhhszdeosYFfNW0WXKQtXIlWB+O4owHJKvEJYaA==", - "license": "MIT", - "engines": { - "node": ">=12.22.0" - } - }, "node_modules/http-errors": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", @@ -1833,12 +1506,6 @@ "url": "https://opencollective.com/express" } }, - "node_modules/http-status-emojis": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/http-status-emojis/-/http-status-emojis-2.2.0.tgz", - "integrity": "sha512-ompKtgwpx8ff0hsbpIB7oE4ax1LXoHmftsHHStMELX56ivG3GhofTX8ZHWlUaFKfGjcGjw6G3rPk7dJRXMmbbg==", - "license": "MIT" - }, "node_modules/iconv-lite": { "version": "0.7.2", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz", @@ -1855,15 +1522,6 @@ "url": "https://opencollective.com/express" } }, - "node_modules/inflection": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/inflection/-/inflection-3.0.2.tgz", - "integrity": "sha512-+Bg3+kg+J6JUWn8J6bzFmOWkTQ6L/NHfDRSYU+EVvuKHDxUDHAXgqixHfVlzuBQaPOTac8hn43aPhMNk6rMe3g==", - "license": "MIT", - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", @@ -1885,60 +1543,6 @@ "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", "license": "MIT" }, - "node_modules/json-server": { - "version": "1.0.0-beta.5", - "resolved": "https://registry.npmjs.org/json-server/-/json-server-1.0.0-beta.5.tgz", - "integrity": "sha512-CvoacHWudRGAlCSnX359W4zTcRSM3FQte2s5rXvWb1R+msDsJNx8AOErFXXmzY6mg3vE5YKJUyFbyUd3YGkiRQ==", - "license": "SEE LICENSE IN ./LICENSE", - "dependencies": { - "@tinyhttp/app": "^3.0.1", - "@tinyhttp/cors": "^2.0.1", - "@tinyhttp/logger": "^2.1.0", - "chalk": "^5.6.2", - "chokidar": "^5.0.0", - "dot-prop": "^10.1.0", - "eta": "^4.5.0", - "inflection": "^3.0.2", - "json5": "^2.2.3", - "lowdb": "^7.0.1", - "milliparsec": "^5.1.0", - "sirv": "^3.0.2", - "sort-on": "^7.0.0" - }, - "bin": { - "json-server": "lib/bin.js" - }, - "engines": { - "node": ">=22.12.0" - } - }, - "node_modules/json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "license": "MIT", - "bin": { - "json5": "lib/cli.js" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/lowdb": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/lowdb/-/lowdb-7.0.1.tgz", - "integrity": "sha512-neJAj8GwF0e8EpycYIDFqEPcx9Qz4GUho20jWFR7YiFeXzF1YMLdxB36PypcTSPMA+4+LvgyMacYhlr18Zlymw==", - "license": "MIT", - "dependencies": { - "steno": "^4.0.2" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/typicode" - } - }, "node_modules/magic-string": { "version": "0.30.21", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", @@ -1979,30 +1583,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/milliparsec": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/milliparsec/-/milliparsec-5.1.0.tgz", - "integrity": "sha512-/xFIv79W7RhnnRLcQOlNpm0xO5FrodBdWFIysI4jIimqCCOnYwBekh6p+Qx61MVooewwBI7WEanFYeo8KtR2dA==", - "license": "MIT", - "engines": { - "node": ">=18.13 || >=19.20 || >=20" - } - }, - "node_modules/mime": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-4.1.0.tgz", - "integrity": "sha512-X5ju04+cAzsojXKes0B/S4tcYtFAJ6tTMuSPBEn9CPGlrWr8Fiw7qYeLT0XyH80HSoAoqWCaz+MWKh22P7G1cw==", - "funding": [ - "https://github.com/sponsors/broofa" - ], - "license": "MIT", - "bin": { - "mime": "bin/cli.js" - }, - "engines": { - "node": ">=16" - } - }, "node_modules/mime-db": { "version": "1.54.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", @@ -2071,15 +1651,6 @@ "node": ">= 0.8" } }, - "node_modules/mrmime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz", - "integrity": "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==", - "license": "MIT", - "engines": { - "node": ">=10" - } - }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -2315,28 +1886,6 @@ "node": ">= 0.10" } }, - "node_modules/readdirp": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.0.0.tgz", - "integrity": "sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ==", - "license": "MIT", - "engines": { - "node": ">= 20.19.0" - }, - "funding": { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/regexparam": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/regexparam/-/regexparam-2.0.2.tgz", - "integrity": "sha512-A1PeDEYMrkLrfyOwv2jwihXbo9qxdGD3atBYQA9JJgreAx8/7rC6IUkWOw2NQlOxLp2wL0ifQbh1HuidDfYA6w==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/rollup": { "version": "4.57.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.57.1.tgz", @@ -2540,35 +2089,6 @@ "dev": true, "license": "ISC" }, - "node_modules/sirv": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.2.tgz", - "integrity": "sha512-2wcC/oGxHis/BoHkkPwldgiPSYcpZK3JU28WoMVv55yHJgcZ8rlXvuG9iZggz+sU1d4bRgIGASwyWqjxu3FM0g==", - "license": "MIT", - "dependencies": { - "@polka/url": "^1.0.0-next.24", - "mrmime": "^2.0.0", - "totalist": "^3.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/sort-on": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/sort-on/-/sort-on-7.0.0.tgz", - "integrity": "sha512-e+4RRxt7jsWdGPp4H5PKOER/ELYlemNB1plvW686Qi3j4WVaCjCpro2zaTD7Cn0VtBImq/hg3x1JfovMNXXfJQ==", - "license": "MIT", - "dependencies": { - "dot-prop": "^10.1.0" - }, - "engines": { - "node": ">=20" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -2602,30 +2122,6 @@ "dev": true, "license": "MIT" }, - "node_modules/steno": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/steno/-/steno-4.0.2.tgz", - "integrity": "sha512-yhPIQXjrlt1xv7dyPQg2P17URmXbuM5pdGkpiMB3RenprfiBlvK415Lctfe0eshk90oA7/tNq7WEiMK8RSP39A==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/typicode" - } - }, - "node_modules/tagged-tag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/tagged-tag/-/tagged-tag-1.0.0.tgz", - "integrity": "sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng==", - "license": "MIT", - "engines": { - "node": ">=20" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/tinybench": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", @@ -2679,30 +2175,6 @@ "node": ">=0.6" } }, - "node_modules/totalist": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", - "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/type-fest": { - "version": "5.4.3", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-5.4.3.tgz", - "integrity": "sha512-AXSAQJu79WGc79/3e9/CR77I/KQgeY1AhNvcShIH4PTcGYyC4xv6H4R4AUOwkPS5799KlVDAu8zExeCrkGquiA==", - "license": "(MIT OR CC0-1.0)", - "dependencies": { - "tagged-tag": "^1.0.0" - }, - "engines": { - "node": ">=20" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/type-is": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", diff --git a/package.json b/package.json index e5fe94d..73e353a 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "dependencies": { "bcrypt": "^6.0.0", "express": "^5.2.1", - "json-server": "^1.0.0-beta.5", "morgan": "^1.10.1" } } From f628d5d20af46e71b6ae784f908ba447443f73d0 Mon Sep 17 00:00:00 2001 From: Jim Cramer Date: Tue, 3 Feb 2026 19:28:55 +0100 Subject: [PATCH 4/7] Update README --- README.md | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 6a1d5e3..237c84c 100644 --- a/README.md +++ b/README.md @@ -6,31 +6,33 @@ Core Program week 9 assignment ### Task 1 -In this task you will practice reading API documentation and using `curl`. The API reference you need is in the [GUIDE.md](task-1/GUIDE.md) file. Read it carefully and construct your own `curl` requests from the endpoint details. +In this task you will practice reading API documentation and using **curl**. The API reference you need is in the [GUIDE.md](task-1/GUIDE.md) file. Read it carefully and construct your own **curl** requests from the endpoint details. Before you start, open a terminal in the repository root and start the server with `npm start`. Keep it running while you work. Create your scripts inside the `task-1` folder and run each script with `bash` after you finish it. If a command fails, compare your request to the examples in the [GUIDE](task-1/GUIDE.md). -1. Create a `post.sh` bash script. It must send a POST request with `curl` to create a new user. Use these values in the JSON body: +1. Create a `post.sh` bash script. It must send a `POST` request with **curl** to create a new user. Use these values in the JSON body: - | Field | Value | - | ----- | ----- | - | name | John Doe | - | email | john.doe@example.com | - | role | user | - | active | true | - | department | Engineering | + | Field | Value | + | ---------- | -------------------- | + | name | John Doe | + | email | john.doe@example.com | + | role | user | + | active | true | + | department | Engineering | - Run the script. Record the `id` in the response. You will use it in the next steps. + Run the script. Record the `id` in the response. You will use it in the next steps. -2. The email address from the previous step mistakenly includes an extra dot between first and last name. We will correct it here. Create a `patch.sh` bash script. It must send a `curl` PATCH request to update only the email for the user you just created. Fix the email by removing the extra dot, changing it to `johndoe@example.com`. Note a PATCH request should include only the field you are updating, in our case this is the `email` field only. +2. The email address from the previous step mistakenly included an extra dot between first and last name. We will correct it here. Create a `patch.sh` bash script. It must send a **curl** `PATCH` request to update the email address for the user you just created. Fix the email by removing the extra dot, changing it to `johndoe@example.com`. Note that in general, a `PATCH` request should include only the field you are updating. In our case this is the `email` field only. -3. Create a `get.sh` script. It must send a `curl` GET request to fetch the user by `id`. Verify the response contains the updated email. +3. Create a `get.sh` script. It must send a **curl** `GET` request to fetch the user by `id`. Verify the response contains the updated email. -4. Create `delete.sh` script. It must send a `curl` DELETE request for the same `id` to remove the user. +4. Create a `delete.sh` script. It must send a **curl** `DELETE` request for the same `id` to remove the user. -5. Re-run the `get.sh` script. The response should now be `User not found`. +5. Re-run the `get.sh` script. The response should now be "User not found". + +When you have completed all steps, stop the server with `Ctrl-C`. ### Task 2 From 92d017deb1af74627fc55944ec06af2ea9263daf Mon Sep 17 00:00:00 2001 From: Jim Cramer Date: Tue, 3 Feb 2026 19:36:23 +0100 Subject: [PATCH 5/7] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 237c84c..dbc8214 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ In this task you will practice reading API documentation and using **curl**. The Before you start, open a terminal in the repository root and start the server with `npm start`. Keep it running while you work. -Create your scripts inside the `task-1` folder and run each script with `bash` after you finish it. If a command fails, compare your request to the examples in the [GUIDE](task-1/GUIDE.md). +Create your scripts inside the `task-1` folder and run each script with `bash` after you finish it. 1. Create a `post.sh` bash script. It must send a `POST` request with **curl** to create a new user. Use these values in the JSON body: From 81a08f74913fee5ef316aad94b17fc5e281945fc Mon Sep 17 00:00:00 2001 From: Tester Date: Wed, 4 Feb 2026 12:41:02 +0100 Subject: [PATCH 6/7] Add autograding tests --- .hyf/test.sh | 6 ++ package.json | 5 +- task-1/server/server.js | 164 +++++++++++++++--------------- task-2/services.js | 3 +- task-1/db.json => tests/seed.json | 49 +++++---- tests/task-1.test.js | 100 ++++++++++++++++++ tests/task-2.test.js | 144 ++++++++++++++++++++++++++ 7 files changed, 369 insertions(+), 102 deletions(-) rename task-1/db.json => tests/seed.json (70%) create mode 100644 tests/task-1.test.js create mode 100644 tests/task-2.test.js diff --git a/.hyf/test.sh b/.hyf/test.sh index 85b02d8..60f266e 100644 --- a/.hyf/test.sh +++ b/.hyf/test.sh @@ -3,8 +3,14 @@ { pushd .. /usr/bin/env npm install + # Start the server + /usr/bin/env npm start & + sleep 3 npx vitest run --reporter=json --outputFile=.hyf/report.json popd || exit } >/dev/null PASSING_SCORE=50 /usr/bin/env node tester.js + +# Kill the server +kill -9 $(lsof -t -i:3000) \ No newline at end of file diff --git a/package.json b/package.json index 73e353a..28ef7d0 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,10 @@ "main": "index.js", "scripts": { "start": "node task-1/server/server.js", - "test": "vitest" + "test": "vitest", + "test:task-1": "vitest tests/task-1.test.js", + "test:task-2": "vitest tests/task-2.test.js", + "test:solution": "SOLUTION_TESTS=1 vitest" }, "keywords": [], "author": "", diff --git a/task-1/server/server.js b/task-1/server/server.js index 3c301c3..b624400 100644 --- a/task-1/server/server.js +++ b/task-1/server/server.js @@ -12,119 +12,123 @@ const app = express(); const PORT = 3000; const usersFilePath = join(__dirname, 'users.json'); -// app.use(morgan('dev')); +app.use(morgan('dev')); app.use(express.json()); // Helper function to read users from the JSON file const readUsers = () => { - const data = fs.readFileSync(usersFilePath); - return JSON.parse(data).users; + const data = fs.readFileSync(usersFilePath); + return JSON.parse(data).users; }; // Helper function to write users to the JSON file const writeUsers = (users) => { - fs.writeFileSync(usersFilePath, JSON.stringify({ users }, null, 2)); + fs.writeFileSync(usersFilePath, JSON.stringify({ users }, null, 2)); }; // GET all users app.get('/users', (req, res) => { - const users = readUsers().map(({ password, ...user }) => user); // Exclude password - res.json(users); + const users = readUsers().map(({ password, ...user }) => user); // Exclude password + res.json(users); }); // GET a user by ID app.get('/users/:id', (req, res) => { - const users = readUsers(); - const user = users.find(u => u.id === parseInt(req.params.id)); - if (user) { - const { password, ...userWithoutPassword } = user; // Exclude password - res.json(userWithoutPassword); - } else { - res.status(404).send('User not found'); - } + const users = readUsers(); + const user = users.find((u) => u.id === parseInt(req.params.id)); + if (user) { + const { password, ...userWithoutPassword } = user; // Exclude password + res.json(userWithoutPassword); + } else { + res.status(404).send('User not found'); + } }); // CREATE a new user app.post('/users', async (req, res) => { - const { name, email, password, role, department } = req.body; - const hashedPassword = await bcrypt.hash(password, 10); - const users = readUsers(); - const newUser = { - id: users.length + 1, - name, - email, - password: hashedPassword, - role, - active: true, - createdAt: new Date().toISOString(), - lastLogin: null, - department - }; - users.push(newUser); - writeUsers(users); - const { password: _, ...userWithoutPassword } = newUser; - res.status(201).json(userWithoutPassword); + const { name, email, password, role, department } = req.body; + const hashedPassword = await bcrypt.hash(password, 10); + const users = readUsers(); + const newUser = { + id: users.length + 1, + name, + email, + password: hashedPassword, + role, + active: true, + createdAt: new Date().toISOString(), + lastLogin: null, + department, + }; + users.push(newUser); + writeUsers(users); + const { password: _, ...userWithoutPassword } = newUser; + res.status(201).json(userWithoutPassword); }); // UPDATE a user by ID app.put('/users/:id', async (req, res) => { - const users = readUsers(); - const userIndex = users.findIndex(u => u.id === parseInt(req.params.id)); - if (userIndex !== -1) { - const { name, email, password, role, department } = req.body; - const updatedUser = { - ...users[userIndex], - name, - email, - role, - department, - ...(password && { password: await bcrypt.hash(password, 10) }) // Update password if provided - }; - users[userIndex] = updatedUser; - writeUsers(users); - const { password: _, ...userWithoutPassword } = updatedUser; - res.json(userWithoutPassword); - } else { - res.status(404).send('User not found'); - } + const users = readUsers(); + const userIndex = users.findIndex((u) => u.id === parseInt(req.params.id)); + if (userIndex !== -1) { + const { name, email, password, role, department } = req.body; + const updatedUser = { + ...users[userIndex], + name, + email, + role, + department, + ...(password && { password: await bcrypt.hash(password, 10) }), // Update password if provided + }; + users[userIndex] = updatedUser; + writeUsers(users); + const { password: _, ...userWithoutPassword } = updatedUser; + res.json(userWithoutPassword); + } else { + res.status(404).send('User not found'); + } }); // PATCH a user by ID (partial update) app.patch('/users/:id', async (req, res) => { - const users = readUsers(); - const userIndex = users.findIndex(u => u.id === parseInt(req.params.id)); - if (userIndex !== -1) { - const updates = { ...req.body }; - // If password is provided, hash it - if (updates.password) { - updates.password = await bcrypt.hash(updates.password, 10); - } - const updatedUser = { - ...users[userIndex], - ...updates - }; - users[userIndex] = updatedUser; - writeUsers(users); - const { password: _, ...userWithoutPassword } = updatedUser; - res.json(userWithoutPassword); - } else { - res.status(404).send('User not found'); + const users = readUsers(); + const userIndex = users.findIndex((u) => u.id === parseInt(req.params.id)); + if (userIndex !== -1) { + const updates = { ...req.body }; + // If password is provided, hash it + if (updates.password) { + updates.password = await bcrypt.hash(updates.password, 10); } + const updatedUser = { + ...users[userIndex], + ...updates, + }; + users[userIndex] = updatedUser; + writeUsers(users); + const { password: _, ...userWithoutPassword } = updatedUser; + res.json(userWithoutPassword); + } else { + res.status(404).send('User not found'); + } }); // DELETE a user by ID app.delete('/users/:id', (req, res) => { - const users = readUsers(); - const userIndex = users.findIndex(u => u.id === parseInt(req.params.id)); - if (userIndex !== -1) { - users.splice(userIndex, 1); - writeUsers(users); - res.status(204).send(); - } else { - res.status(404).send('User not found'); - } + const users = readUsers(); + const userIndex = users.findIndex((u) => u.id === parseInt(req.params.id)); + if (userIndex !== -1) { + users.splice(userIndex, 1); + writeUsers(users); + // Note: The test expects a 200 status code with a success message, but + // typically a 204 No Content is used for successful deletions without + // a response body. + // res.status(204).send(); + res.status(200).send('User deleted successfully'); + } else { + res.status(404).send('User not found'); + } }); app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); \ No newline at end of file + console.log(`Server is running on http://localhost:${PORT}`); +}); diff --git a/task-2/services.js b/task-2/services.js index 45a551c..2126969 100644 --- a/task-2/services.js +++ b/task-2/services.js @@ -15,8 +15,7 @@ const API_BASE_URL = 'https://api.nobelprize.org/2.1'; * @param {Function} onError - Callback for fetch errors */ export function fetchNobelPrizes(filters = {}, onSuccess, onError) { - // TODO: Implement the function to fetch Nobel Prizes from the API - let url = API_BASE_URL; + let url = ''; // TODO Construct the full URL with query parameters; fetchData(url, onSuccess, onError); } diff --git a/task-1/db.json b/tests/seed.json similarity index 70% rename from task-1/db.json rename to tests/seed.json index 8a8bd08..fc8d197 100644 --- a/task-1/db.json +++ b/tests/seed.json @@ -1,102 +1,113 @@ { "users": [ { - "id": "a1b2", + "id": 1, "name": "Alice Johnson", "email": "alice.johnson@example.com", "password": "$2b$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", "role": "admin", "active": true, + "createdAt": "2024-01-15T08:30:00Z", + "lastLogin": "2026-02-03T10:45:00Z", "department": "Engineering" }, { - "id": "c3d4", + "id": 2, "name": "Bob Smith", "email": "bob.smith@example.com", "password": "$2b$10$V8qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", "role": "user", "active": true, + "createdAt": "2024-02-20T09:15:00Z", + "lastLogin": "2026-02-02T14:22:00Z", "department": "Marketing" }, { - "id": "e5f6", + "id": 3, "name": "Carol Williams", "email": "carol.williams@example.com", "password": "$2b$10$X7qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", "role": "moderator", "active": true, + "createdAt": "2024-03-10T11:00:00Z", + "lastLogin": "2026-02-01T09:30:00Z", "department": "Content" }, { - "id": "a7b8", + "id": 4, "name": "David Brown", "email": "david.brown@example.com", "password": "$2b$10$Y6qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", "role": "user", "active": false, + "createdAt": "2024-04-05T13:45:00Z", + "lastLogin": "2025-11-28T16:20:00Z", "department": "Sales" }, { - "id": "c9d0", + "id": 5, "name": "Emma Davis", "email": "emma.davis@example.com", "password": "$2b$10$Z5qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", "role": "admin", "active": true, + "createdAt": "2024-01-08T07:20:00Z", + "lastLogin": "2026-02-03T08:15:00Z", "department": "Engineering" }, { - "id": "e1f2", + "id": 6, "name": "Frank Miller", "email": "frank.miller@example.com", "password": "$2b$10$A4qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", "role": "user", "active": true, + "createdAt": "2024-05-12T10:30:00Z", + "lastLogin": "2026-01-31T12:00:00Z", "department": "HR" }, { - "id": "a3b4", + "id": 7, "name": "Grace Lee", "email": "grace.lee@example.com", "password": "$2b$10$B3qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", "role": "moderator", "active": true, + "createdAt": "2024-06-18T14:15:00Z", + "lastLogin": "2026-02-02T15:45:00Z", "department": "Content" }, { - "id": "c5d6", + "id": 8, "name": "Henry Taylor", "email": "henry.taylor@example.com", "password": "$2b$10$C2qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", "role": "user", "active": false, + "createdAt": "2024-07-22T16:00:00Z", + "lastLogin": "2025-12-15T11:30:00Z", "department": "Finance" }, { - "id": "e7f8", + "id": 9, "name": "Iris Anderson", "email": "iris.anderson@example.com", "password": "$2b$10$D1qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", "role": "user", "active": true, + "createdAt": "2024-08-05T09:45:00Z", + "lastLogin": "2026-02-03T11:20:00Z", "department": "Marketing" }, { - "id": "a9b0", + "id": 10, "name": "Jack Wilson", "email": "jack.wilson@example.com", "password": "$2b$10$E0qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", "role": "moderator", "active": true, - "department": "Engineering" - }, - { - "id": "6f04", - "name": "John Doe", - "email": "john.doe@example.com", - "password": "12345678", - "role": "user", - "active": true, + "createdAt": "2024-09-14T12:30:00Z", + "lastLogin": "2026-02-03T13:00:00Z", "department": "Engineering" } ] diff --git a/tests/task-1.test.js b/tests/task-1.test.js new file mode 100644 index 0000000..8e75f5d --- /dev/null +++ b/tests/task-1.test.js @@ -0,0 +1,100 @@ +import { exec } from 'child_process'; +import { existsSync, readFileSync, writeFileSync } from 'fs'; +import path from 'path'; +import { promisify } from 'util'; +import { beforeAll, describe, expect, test } from 'vitest'; + +const execPromise = promisify(exec); + +let scriptDir; + +if (process.env.SOLUTION_TESTS) { + scriptDir = path.join(__dirname, '../solutions/task-1'); +} else { + scriptDir = path.join(__dirname, '../task-1'); +} + +const serverDir = path.join(__dirname, '../task-1/server'); + +beforeAll(() => { + const seedJson = readFileSync(path.join(__dirname, 'seed.json'), 'utf-8'); + writeFileSync(path.join(serverDir, 'users.json'), seedJson, 'utf-8'); +}); + +describe('curl scripts', () => { + test('post.sh: Script exists', async () => { + const fileExists = existsSync(path.join(scriptDir, 'post.sh')); + expect(fileExists).toBe(true); + }); + + test('post.sh: Create user John Doe', async () => { + const { stdout } = await execPromise( + `bash ${path.join(scriptDir, 'post.sh')}` + ); + try { + const user = JSON.parse(stdout); + expect(user).toHaveProperty('id'); + expect(user).toHaveProperty('name', 'John Doe'); + expect(user).toHaveProperty('email', 'john.doe@example.com'); + } catch (error) { + throw new Error(`Failed to parse JSON: ${error.message}`); + } + }); + + test('patch.sh: Script exists', async () => { + const fileExists = existsSync(path.join(scriptDir, 'patch.sh')); + expect(fileExists).toBe(true); + }); + + test('patch.sh: Correct the email address', async () => { + const { stdout } = await execPromise( + `bash ${path.join(scriptDir, 'patch.sh')}` + ); + try { + const user = JSON.parse(stdout); + expect(user).toHaveProperty('email', 'johndoe@example.com'); + } catch (error) { + throw new Error(`Failed to parse JSON: ${error.message}`); + } + }); + + test('get.sh: Script exists', async () => { + const fileExists = existsSync(path.join(scriptDir, 'get.sh')); + expect(fileExists).toBe(true); + }); + + test('get.sh: Retrieve user John Doe details', async () => { + const { stdout } = await execPromise( + `bash ${path.join(scriptDir, 'get.sh')}` + ); + try { + const user = JSON.parse(stdout); + expect(user).toHaveProperty('id', 11); + } catch (error) { + throw new Error(`Failed to parse JSON: ${error.message}`); + } + }); + + test('delete.sh: Script exists', async () => { + const fileExists = existsSync(path.join(scriptDir, 'delete.sh')); + expect(fileExists).toBe(true); + }); + + test('delete.sh: Delete user John Doe', async () => { + const { stdout } = await execPromise( + `bash ${path.join(scriptDir, 'delete.sh')}` + ); + try { + expect(stdout).toBe('User deleted successfully'); + } catch (error) { + throw new Error(`Failed to parse JSON: ${error.message}`); + } + }); + + test('get.sh: Verify user John Doe has been deleted', async () => { + const { stdout } = await execPromise( + `bash ${path.join(scriptDir, 'get.sh')}` + ); + expect(stdout).toBe('User not found'); + }); +}); diff --git a/tests/task-2.test.js b/tests/task-2.test.js new file mode 100644 index 0000000..17d89d1 --- /dev/null +++ b/tests/task-2.test.js @@ -0,0 +1,144 @@ +import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'; +import { fetchNobelPrizes } from '../task-2/services.js'; + +beforeEach(async () => { + global.fetch = vi.fn(() => + Promise.resolve({ + ok: true, + json: () => Promise.resolve('{}'), + }) + ); +}); +afterEach(() => { + vi.resetAllMocks(); +}); + +describe('fetchNobelPrizes', () => { + test('Uses the correct base URL', () => { + const onSuccess = vi.fn(); + const onError = vi.fn(); + + fetchNobelPrizes( + { year: '2020', category: 'phy', offset: 5, limit: 15 }, + onSuccess, + onError + ); + + expect(global.fetch).toHaveBeenCalledWith( + expect.stringContaining('https://api.nobelprize.org/2.1') + ); + }); + + test('URL includes the nobelPrizeYear query parameter', () => { + const onSuccess = vi.fn(); + const onError = vi.fn(); + + fetchNobelPrizes( + { year: '2020', category: 'che', offset: 10, limit: 20 }, + onSuccess, + onError + ); + + expect(global.fetch).toHaveBeenCalledWith( + expect.stringContaining('nobelPrizeYear=2020') + ); + }); + + test('URL includes the nobelPrizeCategory query parameter', () => { + const onSuccess = vi.fn(); + const onError = vi.fn(); + + fetchNobelPrizes( + { year: '2020', category: 'che', offset: 10, limit: 20 }, + onSuccess, + onError + ); + + expect(global.fetch).toHaveBeenCalledWith( + expect.stringContaining('nobelPrizeCategory=che') + ); + }); + + test('URL includes the offset query parameter', () => { + const onSuccess = vi.fn(); + const onError = vi.fn(); + + fetchNobelPrizes( + { year: '2020', category: 'che', offset: 10, limit: 20 }, + onSuccess, + onError + ); + + expect(global.fetch).toHaveBeenCalledWith( + expect.stringContaining('offset=10') + ); + }); + + test('URL includes the limit query parameter', () => { + const onSuccess = vi.fn(); + const onError = vi.fn(); + + fetchNobelPrizes( + { year: '2020', category: 'che', offset: 10, limit: 20 }, + onSuccess, + onError + ); + + expect(global.fetch).toHaveBeenCalledWith( + expect.stringContaining('limit=20') + ); + }); + + test('Omits the nobelPrizeYear when set to "all"', () => { + const onSuccess = vi.fn(); + const onError = vi.fn(); + + fetchNobelPrizes( + { year: 'all', category: 'che', offset: 0, limit: 10 }, + onSuccess, + onError + ); + + expect(global.fetch).toHaveBeenCalledWith( + expect.stringContaining('https://api.nobelprize.org/2.1') + ); + + expect(global.fetch).toHaveBeenCalledWith( + expect.not.stringContaining('nobelPrizeYear=') + ); + }); + + test('Omits the nobelPrizeCategory when set to "all"', () => { + const onSuccess = vi.fn(); + const onError = vi.fn(); + + fetchNobelPrizes( + { year: '2020', category: 'all', offset: 0, limit: 10 }, + onSuccess, + onError + ); + + expect(global.fetch).toHaveBeenCalledWith( + expect.stringContaining('https://api.nobelprize.org/2.1') + ); + + expect(global.fetch).toHaveBeenCalledWith( + expect.not.stringContaining('nobelPrizeCategory=') + ); + }); + + test('Includes the sort query parameter set to desc', () => { + const onSuccess = vi.fn(); + const onError = vi.fn(); + + fetchNobelPrizes( + { year: '2020', category: 'che', offset: 0, limit: 10 }, + onSuccess, + onError + ); + + expect(global.fetch).toHaveBeenCalledWith( + expect.stringContaining('sort=desc') + ); + }); +}); From b62d30664d958735f90b5dfbe218590cb5ce8348 Mon Sep 17 00:00:00 2001 From: Tester Date: Wed, 4 Feb 2026 12:43:34 +0100 Subject: [PATCH 7/7] fail --- task-1/GUIDE.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/task-1/GUIDE.md b/task-1/GUIDE.md index 2c9f24d..aed3e2f 100644 --- a/task-1/GUIDE.md +++ b/task-1/GUIDE.md @@ -1,6 +1,6 @@ # Users API — Usage Guide -This guide describes the users API backed by the local users.json file. It explains the endpoints, required data, and expected behavior so you can build your own requests. +This guide describes the users API backed by the local users.json file. It explains the endpoints, required data, and expected behavior so you can build your own requests Base URL: @@ -28,7 +28,6 @@ Response: an array of users (without `password`). - Method: POST - Path: /users - Body: JSON with the following fields: - - `name` (string) - `email` (string) - `password` (string, required)