From 6de747d6f5189cf5ae2444bfa4036b60d72c9516 Mon Sep 17 00:00:00 2001 From: Dagim02 Date: Wed, 11 Mar 2026 11:46:29 +0100 Subject: [PATCH 1/2] Fix Nobel Prize URL filtering logic --- package-lock.json | 4 +- task-1/server/users.json | 82 ++++++++++++++++++++-------------------- task-2/services.js | 17 +++++++-- 3 files changed, 57 insertions(+), 46 deletions(-) diff --git a/package-lock.json b/package-lock.json index 020596f..837218f 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": { diff --git a/task-1/server/users.json b/task-1/server/users.json index fc8d197..f83dfe0 100644 --- a/task-1/server/users.json +++ b/task-1/server/users.json @@ -1,16 +1,5 @@ { "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", @@ -24,18 +13,18 @@ }, { "id": 3, - "name": "Carol Williams", - "email": "carol.williams@example.com", + "name": "jan van dorp", + "email": "janvandorp@gmail.com", "password": "$2b$10$X7qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", "role": "moderator", - "active": true, + "active": false, "createdAt": "2024-03-10T11:00:00Z", "lastLogin": "2026-02-01T09:30:00Z", "department": "Content" }, { "id": 4, - "name": "David Brown", + "name": "Joseph Townman", "email": "david.brown@example.com", "password": "$2b$10$Y6qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", "role": "user", @@ -46,14 +35,14 @@ }, { "id": 5, - "name": "Emma Davis", - "email": "emma.davis@example.com", - "password": "$2b$10$Z5qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", - "role": "admin", + "name": "marijke van western", + "email": "marijkevanwestern@example.com", + "password": "$2b$10$LKi7xwJFALpHzqt0FQw8xOD1nLGTDTncqDbe9tk9DUrrIL3ON5jmW", + "role": "moderatore", "active": true, "createdAt": "2024-01-08T07:20:00Z", "lastLogin": "2026-02-03T08:15:00Z", - "department": "Engineering" + "department": "Food Science" }, { "id": 6, @@ -77,38 +66,49 @@ "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", + "name": "Tom Jerry", + "email": "tomjerry@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" + "department": "ICT" }, { "id": 10, - "name": "Jack Wilson", - "email": "jack.wilson@example.com", - "password": "$2b$10$E0qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", - "role": "moderator", + "name": "Jim Thomas", + "email": "jimthomas@gmail.com", + "password": "$2b$10$fJOn9SFOf3R6fVotlx..ruwRg92M7.WERtBTq6a/L9elqtIFXltry", + "role": "user", + "active": true, + "createdAt": "2026-03-10T23:55:06.427Z", + "lastLogin": null, + "department": "Social Science" + }, + { + "id": 11, + "name": "Henok Tota", + "email": "henoktota@gmail.com", + "password": "$2b$10$3tayN3ydfMi32Kt4Vf4rPuQBd3hyr2F4iVnC.JjShUEitiEgg1tay", + "role": "student", + "active": true, + "createdAt": "2026-03-11T07:41:34.250Z", + "lastLogin": null, + "department": "Animal science" + }, + { + "id": 12, + "name": "Joel lucas", + "email": "joellucas@gmail.com", + "password": "$2b$10$SddQrXivrzw4M9o0EcN0sOnkC0WraHs3PSm1Y85raB8OHLG6Z9cAe", + "role": "user", "active": true, - "createdAt": "2024-09-14T12:30:00Z", - "lastLogin": "2026-02-03T13:00:00Z", - "department": "Engineering" + "createdAt": "2026-03-11T08:04:28.759Z", + "lastLogin": null, + "department": "IT" } ] } \ No newline at end of file diff --git a/task-2/services.js b/task-2/services.js index 2126969..503f608 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,18 @@ 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; + // TODO Construct the full URL with query parameters + let url = + `${API_BASE_URL}/nobelPrizes?` + + new URLSearchParams({ + ...(filters.year !== "all" && { nobelPrizeYear: filters.year }), + ...(filters.category !== "all" && { + nobelPrizeCategory: filters.category, + }), + offset: filters.offset || 0, + limit: filters.limit || 10, + sort: "desc", + }); fetchData(url, onSuccess, onError); } From 4c90b7fb6d5a64669c272a8a38f5b0d257431965 Mon Sep 17 00:00:00 2001 From: Dagim02 Date: Wed, 11 Mar 2026 14:45:40 +0100 Subject: [PATCH 2/2] task-1: bash scripts ! --- task-1/delete.sh | 2 + task-1/get.sh | 2 + task-1/patch.sh | 6 +++ task-1/post.sh | 11 ++++++ task-1/server/users.json | 82 ++++++++++++++++++++-------------------- 5 files changed, 62 insertions(+), 41 deletions(-) create mode 100644 task-1/delete.sh create mode 100644 task-1/get.sh create mode 100644 task-1/patch.sh create mode 100644 task-1/post.sh diff --git a/task-1/delete.sh b/task-1/delete.sh new file mode 100644 index 0000000..05ce47d --- /dev/null +++ b/task-1/delete.sh @@ -0,0 +1,2 @@ +#!/bin/bash +curl -X DELETE http://localhost:3000/users/11 \ No newline at end of file diff --git a/task-1/get.sh b/task-1/get.sh new file mode 100644 index 0000000..bc02d9f --- /dev/null +++ b/task-1/get.sh @@ -0,0 +1,2 @@ +#!/bin/bash +curl -X GET http://localhost:3000/users/11 \ No newline at end of file diff --git a/task-1/patch.sh b/task-1/patch.sh new file mode 100644 index 0000000..496d806 --- /dev/null +++ b/task-1/patch.sh @@ -0,0 +1,6 @@ +#!/bin/bash +curl -X PATCH http://localhost:3000/users/11 \ +-H "Content-Type: application/json" \ +-d '{ + "email": "johndoe@example.com" +}' \ No newline at end of file diff --git a/task-1/post.sh b/task-1/post.sh new file mode 100644 index 0000000..1c5d472 --- /dev/null +++ b/task-1/post.sh @@ -0,0 +1,11 @@ +#!/bin/bash +curl -X POST http://localhost:3000/users \ +-H "Content-Type: application/json" \ +-d '{ + "name": "John Doe", + "email": "john.doe@example.com", + "password": "secret123", + "role": "user", + "active": true, + "department": "Engineering" +}' \ No newline at end of file diff --git a/task-1/server/users.json b/task-1/server/users.json index f83dfe0..fc8d197 100644 --- a/task-1/server/users.json +++ b/task-1/server/users.json @@ -1,5 +1,16 @@ { "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", @@ -13,18 +24,18 @@ }, { "id": 3, - "name": "jan van dorp", - "email": "janvandorp@gmail.com", + "name": "Carol Williams", + "email": "carol.williams@example.com", "password": "$2b$10$X7qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", "role": "moderator", - "active": false, + "active": true, "createdAt": "2024-03-10T11:00:00Z", "lastLogin": "2026-02-01T09:30:00Z", "department": "Content" }, { "id": 4, - "name": "Joseph Townman", + "name": "David Brown", "email": "david.brown@example.com", "password": "$2b$10$Y6qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", "role": "user", @@ -35,14 +46,14 @@ }, { "id": 5, - "name": "marijke van western", - "email": "marijkevanwestern@example.com", - "password": "$2b$10$LKi7xwJFALpHzqt0FQw8xOD1nLGTDTncqDbe9tk9DUrrIL3ON5jmW", - "role": "moderatore", + "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": "Food Science" + "department": "Engineering" }, { "id": 6, @@ -66,49 +77,38 @@ "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": "Tom Jerry", - "email": "tomjerry@example.com", + "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": "ICT" + "department": "Marketing" }, { "id": 10, - "name": "Jim Thomas", - "email": "jimthomas@gmail.com", - "password": "$2b$10$fJOn9SFOf3R6fVotlx..ruwRg92M7.WERtBTq6a/L9elqtIFXltry", - "role": "user", - "active": true, - "createdAt": "2026-03-10T23:55:06.427Z", - "lastLogin": null, - "department": "Social Science" - }, - { - "id": 11, - "name": "Henok Tota", - "email": "henoktota@gmail.com", - "password": "$2b$10$3tayN3ydfMi32Kt4Vf4rPuQBd3hyr2F4iVnC.JjShUEitiEgg1tay", - "role": "student", - "active": true, - "createdAt": "2026-03-11T07:41:34.250Z", - "lastLogin": null, - "department": "Animal science" - }, - { - "id": 12, - "name": "Joel lucas", - "email": "joellucas@gmail.com", - "password": "$2b$10$SddQrXivrzw4M9o0EcN0sOnkC0WraHs3PSm1Y85raB8OHLG6Z9cAe", - "role": "user", + "name": "Jack Wilson", + "email": "jack.wilson@example.com", + "password": "$2b$10$E0qo8uLOickgx2ZMRZoMyeIjZAgcg7b3XeKeUxWdeS86E36P4/TVG2", + "role": "moderator", "active": true, - "createdAt": "2026-03-11T08:04:28.759Z", - "lastLogin": null, - "department": "IT" + "createdAt": "2024-09-14T12:30:00Z", + "lastLogin": "2026-02-03T13:00:00Z", + "department": "Engineering" } ] } \ No newline at end of file