Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions task-1/delete.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

curl -X DELETE http://localhost:3000/users/11
3 changes: 3 additions & 0 deletions task-1/get.sh
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works because curl uses GET by default. However, I'd consider adding -X GET to make the method explicit and consistent with your other bash scripts.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

curl http://localhost:3000/users/11
7 changes: 7 additions & 0 deletions task-1/patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

curl -X PATCH http://localhost:3000/users/11 \
-H "Content-Type: application/json" \
-d '{
"email": "johndoe@example.com"
}'
12 changes: 12 additions & 0 deletions task-1/post.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/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"
}'
11 changes: 11 additions & 0 deletions task-1/server/users.json
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I believe the users.json file was supposed to remain in the same state as at the beginning of the project. It's not the focus of the exercise, and it's not an issue either, but it's good to be cautious when committing changes to 'database' files like this one.

Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@
"createdAt": "2024-09-14T12:30:00Z",
"lastLogin": "2026-02-03T13:00:00Z",
"department": "Engineering"
},
{
"id": 11,
"name": "John Doe",
"email": "john.doe@example.com",
"password": "$2b$10$lx9RKgxUq9f39zi0cX4j8ODwemMIQ903up40U8LX.EecWGi6rqVKK",
"role": "user",
"active": true,
"createdAt": "2026-03-11T16:09:53.518Z",
"lastLogin": null,
"department": "Engineering"
}
]
}
21 changes: 19 additions & 2 deletions task-2/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { fetchData } from './fetcher.js';

const API_BASE_URL = 'https://api.nobelprize.org/2.1';

// https://api.nobelprize.org/2.1/nobelPrizes?offset=0&limit=10&sort=desc
// https://api.nobelprize.org/2.1/nobelPrizes?offset=0&limit=10&sort=desc[&nobelPrizeYear=2020][&nobelPrizeCategory=physics]

/**
* Fetch Nobel Prizes with optional filters
* @param {Object} filters - Filter options
Expand All @@ -15,7 +18,21 @@ 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;
let url = `${API_BASE_URL}/nobelPrizes`;
const params = new URLSearchParams({
offset: filters.offset || 0,
limit: filters.limit || 10,
sort: 'desc'
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of the URLSearchParams object constructor for the fixed params 👍


// Only add optional filters when not "all"
if (filters.year !== 'all') {
params.set('nobelPrizeYear', filters.year);
}
if (filters.category !== 'all') {
params.set('nobelPrizeCategory', filters.category);
}

url += `?${params}`; //ADD the query string to the end of url
fetchData(url, onSuccess, onError);
}
}