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
6 changes: 2 additions & 4 deletions package-lock.json

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

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

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"
8 changes: 8 additions & 0 deletions task-1/get.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

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" \
9 changes: 9 additions & 0 deletions task-1/patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

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" \
-d '{"email": "johndoe@example.com"}'
17 changes: 17 additions & 0 deletions task-1/post.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/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"}')

echo "$response"

id_line=$(echo "$response" | grep '"id"')

id=$(echo "$id_line" | tr -cd '0-9')

echo "$id" > "$SCRIPT_DIR/id.txt"


2 changes: 1 addition & 1 deletion task-1/server/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@
"department": "Engineering"
}
]
}
}
16 changes: 13 additions & 3 deletions task-2/services.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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);
}