From 3753ea8651812f69ac5b69402bdf12f04ae368a4 Mon Sep 17 00:00:00 2001 From: Yana Pechenenko Date: Tue, 10 Mar 2026 17:25:00 +0100 Subject: [PATCH 1/4] add post method for task-1 --- package-lock.json | 6 ++---- task-1/id.txt | 1 + task-1/post.sh | 17 +++++++++++++++++ task-1/server/users.json | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 task-1/id.txt create mode 100644 task-1/post.sh diff --git a/package-lock.json b/package-lock.json index 020596f..1dee487 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "core-assignment-week-10", + "name": "core-assignment-week-9", "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "core-assignment-week-10", + "name": "core-assignment-week-9", "version": "1.0.0", "license": "ISC", "dependencies": { @@ -1810,7 +1810,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -2226,7 +2225,6 @@ "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", diff --git a/task-1/id.txt b/task-1/id.txt new file mode 100644 index 0000000..d6b2404 --- /dev/null +++ b/task-1/id.txt @@ -0,0 +1 @@ +19 diff --git a/task-1/post.sh b/task-1/post.sh new file mode 100644 index 0000000..f336da1 --- /dev/null +++ b/task-1/post.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +response=$(curl -X POST http://localhost:3000/users \ + -H "Content-Type: application/json; charset=UTF-8" \ + -d '{"name":"John Doe", "email": "john.doe@example.com", "password": "secret123", "role": "user", "active": true, "department": "Engineering"}') + + echo "Response from server" + echo "$response" + + id_line=$(echo "$response" | grep '"id"') + + id=$(echo "$id_line" | tr -cd '0-9') + + echo "$id" > task-1/id.txt + + echo "Saved id: $id" + diff --git a/task-1/server/users.json b/task-1/server/users.json index fc8d197..f06616b 100644 --- a/task-1/server/users.json +++ b/task-1/server/users.json @@ -111,4 +111,4 @@ "department": "Engineering" } ] -} \ No newline at end of file +} From 292a2905c51953894d72a87ff65d4aca1d9af783 Mon Sep 17 00:00:00 2001 From: Yana Pechenenko Date: Wed, 11 Mar 2026 17:39:56 +0100 Subject: [PATCH 2/4] Finish task-1 --- task-1/delete.sh | 6 ++++++ task-1/get.sh | 6 ++++++ task-1/id.txt | 2 +- task-1/patch.sh | 7 +++++++ task-1/post.sh | 3 --- task-1/server/users.json | 2 +- 6 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 task-1/delete.sh create mode 100644 task-1/get.sh create mode 100644 task-1/patch.sh diff --git a/task-1/delete.sh b/task-1/delete.sh new file mode 100644 index 0000000..2754d3e --- /dev/null +++ b/task-1/delete.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +id=$(cat task-1/id.txt) + +curl -X DELETE http://localhost:3000/users/$id \ + -H "Content-Type: application/json; charset=UTF-8" \ No newline at end of file diff --git a/task-1/get.sh b/task-1/get.sh new file mode 100644 index 0000000..83c7395 --- /dev/null +++ b/task-1/get.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +id=$(cat task-1/id.txt) + +curl -X GET http://localhost:3000/users/$id \ + -H "Content-Type: application/json; charset=UTF-8" \ \ No newline at end of file diff --git a/task-1/id.txt b/task-1/id.txt index d6b2404..b4de394 100644 --- a/task-1/id.txt +++ b/task-1/id.txt @@ -1 +1 @@ -19 +11 diff --git a/task-1/patch.sh b/task-1/patch.sh new file mode 100644 index 0000000..28ca595 --- /dev/null +++ b/task-1/patch.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +id=$(cat task-1/id.txt) + +curl -X PATCH http://localhost:3000/users/$id \ + -H "Content-Type: application/json; charset=UTF-8" \ + -d '{"email": "johndoe@example.com"}' diff --git a/task-1/post.sh b/task-1/post.sh index f336da1..2f2e23a 100644 --- a/task-1/post.sh +++ b/task-1/post.sh @@ -4,7 +4,6 @@ response=$(curl -X POST http://localhost:3000/users \ -H "Content-Type: application/json; charset=UTF-8" \ -d '{"name":"John Doe", "email": "john.doe@example.com", "password": "secret123", "role": "user", "active": true, "department": "Engineering"}') - echo "Response from server" echo "$response" id_line=$(echo "$response" | grep '"id"') @@ -12,6 +11,4 @@ response=$(curl -X POST http://localhost:3000/users \ id=$(echo "$id_line" | tr -cd '0-9') echo "$id" > task-1/id.txt - - echo "Saved id: $id" diff --git a/task-1/server/users.json b/task-1/server/users.json index f06616b..fc8d197 100644 --- a/task-1/server/users.json +++ b/task-1/server/users.json @@ -111,4 +111,4 @@ "department": "Engineering" } ] -} +} \ No newline at end of file From d57154128d0b616e325529a692cb76ec59cda38b Mon Sep 17 00:00:00 2001 From: Yana Pechenenko Date: Wed, 11 Mar 2026 18:36:20 +0100 Subject: [PATCH 3/4] Finish task 2 --- task-2/services.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/task-2/services.js b/task-2/services.js index 2126969..fdffe01 100644 --- a/task-2/services.js +++ b/task-2/services.js @@ -1,8 +1,8 @@ // Nobel Prize API Documentation: https://www.nobelprize.org/about/developer-zone-2/ -import { fetchData } from './fetcher.js'; +import { fetchData } from "./fetcher.js"; -const API_BASE_URL = 'https://api.nobelprize.org/2.1'; +const API_BASE_URL = "https://api.nobelprize.org/2.1"; /** * Fetch Nobel Prizes with optional filters @@ -15,7 +15,17 @@ const API_BASE_URL = 'https://api.nobelprize.org/2.1'; * @param {Function} onError - Callback for fetch errors */ export function fetchNobelPrizes(filters = {}, onSuccess, onError) { - let url = ''; // TODO Construct the full URL with query parameters; + const { year = "all", category = "all", offset = 0, limit = 10 } = filters; + + let url = `${API_BASE_URL}/nobelPrizes?offset=${offset}&limit=${limit}&sort=desc`; + + if (year !== "all") { + url += `&nobelPrizeYear=${year}`; + } + + if (category !== "all") { + url += `&nobelPrizeCategory=${category}`; + } fetchData(url, onSuccess, onError); } From 1119b3eeb898fe031e6c0198581259dfbdf1930c Mon Sep 17 00:00:00 2001 From: Yana Pechenenko Date: Sat, 28 Mar 2026 17:45:41 +0100 Subject: [PATCH 4/4] fix(task-1): absolute paths refactor(task-2): use URLSearchParams --- task-1/delete.sh | 4 +++- task-1/get.sh | 4 +++- task-1/id.txt | 1 - task-1/patch.sh | 4 +++- task-1/post.sh | 5 ++++- task-1/server/users.json | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) delete mode 100644 task-1/id.txt diff --git a/task-1/delete.sh b/task-1/delete.sh index 2754d3e..32331b9 100644 --- a/task-1/delete.sh +++ b/task-1/delete.sh @@ -1,6 +1,8 @@ #!/bin/bash -id=$(cat task-1/id.txt) +SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) + +id=$(cat "$SCRIPT_DIR/id.txt") curl -X DELETE http://localhost:3000/users/$id \ -H "Content-Type: application/json; charset=UTF-8" \ No newline at end of file diff --git a/task-1/get.sh b/task-1/get.sh index 83c7395..946cfeb 100644 --- a/task-1/get.sh +++ b/task-1/get.sh @@ -1,6 +1,8 @@ #!/bin/bash -id=$(cat task-1/id.txt) +SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) + +id=$(cat "$SCRIPT_DIR/id.txt") curl -X GET http://localhost:3000/users/$id \ -H "Content-Type: application/json; charset=UTF-8" \ \ No newline at end of file diff --git a/task-1/id.txt b/task-1/id.txt deleted file mode 100644 index b4de394..0000000 --- a/task-1/id.txt +++ /dev/null @@ -1 +0,0 @@ -11 diff --git a/task-1/patch.sh b/task-1/patch.sh index 28ca595..7aed03c 100644 --- a/task-1/patch.sh +++ b/task-1/patch.sh @@ -1,6 +1,8 @@ #!/bin/bash -id=$(cat task-1/id.txt) +SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) + +id=$(cat "$SCRIPT_DIR/id.txt") curl -X PATCH http://localhost:3000/users/$id \ -H "Content-Type: application/json; charset=UTF-8" \ diff --git a/task-1/post.sh b/task-1/post.sh index 2f2e23a..8534cbd 100644 --- a/task-1/post.sh +++ b/task-1/post.sh @@ -1,5 +1,7 @@ #!/bin/bash +SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) + response=$(curl -X POST http://localhost:3000/users \ -H "Content-Type: application/json; charset=UTF-8" \ -d '{"name":"John Doe", "email": "john.doe@example.com", "password": "secret123", "role": "user", "active": true, "department": "Engineering"}') @@ -10,5 +12,6 @@ response=$(curl -X POST http://localhost:3000/users \ id=$(echo "$id_line" | tr -cd '0-9') - echo "$id" > task-1/id.txt + echo "$id" > "$SCRIPT_DIR/id.txt" + diff --git a/task-1/server/users.json b/task-1/server/users.json index fc8d197..f06616b 100644 --- a/task-1/server/users.json +++ b/task-1/server/users.json @@ -111,4 +111,4 @@ "department": "Engineering" } ] -} \ No newline at end of file +}