Skip to content

Yana P.#10

Open
YanaP1312 wants to merge 4 commits intoHackYourAssignment:mainfrom
YanaP1312:main
Open

Yana P.#10
YanaP1312 wants to merge 4 commits intoHackYourAssignment:mainfrom
YanaP1312:main

Conversation

@YanaP1312
Copy link
Copy Markdown

Task 1 – Cocktail Recipe CLI: Built a small command‑line tool that retrieves cocktail data from TheCocktailDB API and saves the recipe as a Markdown file using async/await and fs/promises.

Task 2 – Post Central API Services: Completed the required API service functions for the CLI by implementing the missing GET, POST, PUT, and DELETE requests and connecting them to the existing project structure.

@github-actions

This comment has been minimized.

@JQnetherlands JQnetherlands self-requested a review March 19, 2026 10:58
@JQnetherlands JQnetherlands self-assigned this Mar 19, 2026
Comment thread task-1/cocktail.js Outdated

// Add helper functions as needed here

function generateMarkdownContent(data) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Well done, encapsulating your code in a function make it reusable

Comment thread task-1/cocktail.js
}

function cocktailIngredients(drink) {
if (!drink) return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Well done, encapsulating your code in a function make it reusable

Comment thread task-1/cocktail.js

let ingredients = [];

for (let i = 1; i <= 15; i++) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nice loop

Comment thread task-2/post-cli/src/services.js Outdated

if (!response.ok) {
throw new Error(
`Failed to getMe : HTTP ${response.status} ${response.statusText}`,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

see my main comment

Comment thread task-2/post-cli/src/services.js Outdated

if (!response.ok) {
throw new Error(
`Failed to login user: HTTP ${response.status} ${response.statusText}`,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

see my main comment

Comment thread task-2/post-cli/src/services.js Outdated
});
if (!response.ok) {
throw new Error(
`Failed to create a post: HTTP ${response.status} ${response.statusText}`,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

see my main comment

Comment thread task-2/post-cli/src/services.js Outdated

if (!response.ok) {
throw new Error(
`Failed to get posts: HTTP ${response.status} ${response.statusText}`,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

see my main comment

Comment thread task-2/post-cli/src/services.js Outdated

if (!response.ok) {
throw new Error(
`Failed to delete user: HTTP ${response.status} ${response.statusText}`,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

see my main comment

Comment thread task-2/post-cli/src/services.js Outdated
`Failed to delete post: HTTP ${response.status} ${response.statusText}`,
);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

see my main comment

Copy link
Copy Markdown

@JQnetherlands JQnetherlands left a comment

Choose a reason for hiding this comment

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

Hello, Yanna.

I will start with the good news! you have passed both task successfully, you almost have exceeds expectations ( almost 5 starts), now I will go on with the nices to have.

About task 1 you created two functions, that made your code reusable for future projects, You are in the right track, sometimes after you do a project , review the functions you made after a while maybe you will have that aha moment, where you see that you could have done refactoring in other way, that is a skill that only come with the time, what I advice you to review this project again after some time!

I do love that you used a for loop, well done, I invite you to think where else you could have done, for your personal grow!

About task 2, all your functions accomplish their goal , well done, each of one shows you do understand the CRUD and HTTP actions and what each Method needs to successfully fetch to the back end (GET, POST, UPDATE, DELETE).

The only feedback I have to write better code is the following:

Right now you have ---> Failed to delete post: HTTP ${response.status} ${response.statusText}

That would be ---> Failed to delete post: HTTP 403 forbidden

Do you think it is clear enough information for the user to know what went wrong?
Can you imagine a better statement for the user?

for example this you could do if you change your code a bit, I will give you the final expected output that I am talking about:

clearer output ---> Failed to delete post: HTTP 403 You can only modify your own posts

Do you see the difference? can you imagine how you could make your code give that example? HINT: maybe an inline conditional , do you know which one?

That you could apply to each function to make it more user friendly.

Again, you did super well overall, keep the good work! Congratulations

@JQnetherlands JQnetherlands added the Reviewed This assignment has been reivewed by a mentor and a feedback has been provided label Mar 25, 2026
@github-actions
Copy link
Copy Markdown

📝 HackYourFuture auto grade

Assignment Score: 93 / 100 ✅

Status: ✅ Passed
Minimum score to pass: 50
🧪 The auto grade is experimental and still being improved

Test Details
Vitest unit test results:

✅ [10] Markdown file created
✅ [1] Content starts with # Cocktail Recipes
✅ [1] Content includes drink name as ## Margarita
✅ [1] Content includes medium drink image
✅ [1] Content includes category and alcoholic info
✅ [1] Content includes header ### Ingredients
✅ [1] Content includes ingredients list
✅ [1] Content includes header ### Instructions
✅ [1] Content includes instruction details
✅ [1] Content includes glass type
✅ [1] Calls console.error() if no cocktail name argument provided
✅ [1] Calls console.error() if cocktail not found
✅ [1] Calls console.error() if fetch was not OK
❌ should complete all CRUD operations successfully
✅ should verify updatePost uses PUT method with Authorization
❌ should verify deleteUser uses DELETE method with Authorization
❌ should verify deletePost uses DELETE method with Authorization
✅ should verify getMe fetches current user info with Authorization
✅ should handle errors in any CRUD operation
✅ should make GET request to /users/me with Authorization header
✅ should return user information with correct structure
✅ should throw error when response is not ok (404)
✅ should make GET request to /posts/me with Authorization header
✅ should return an array of posts
✅ should return empty array when no posts exist
✅ should make POST request to /users/register with correct data
✅ should return user data with correct structure
✅ should include Content-Type header
✅ should throw error when API returns error
✅ should make POST request to /users/login with correct data
✅ should return user data with token
✅ should throw error on invalid credentials
✅ should make POST request to /posts with correct data and Authorization header
✅ should return post data with correct structure
✅ should include Content-Type and Authorization headers
✅ should throw error when not authenticated

Total passed: 33
Total failed: 3

@YanaP1312
Copy link
Copy Markdown
Author

Refactor: improve error messages and code structure across tasks 1 & 2

Task 1:

  • Broke down generateMarkdownContent() into smaller, clearer formatting helpers
  • Improved readability by separating heading, thumbnail, category, alcoholic flag, instructions and glass type
  • Simplified main() flow with fetchCocktailData(), validation and saveMarkdown()
  • Made the overall structure cleaner and easier to maintain

Task 2:

  • Added friendly, human‑readable error messages based on HTTP status codes
    (e.g. 403 → "You can only modify your own posts")
  • Updated CRUD functions to use a shared apiRequest() helper
  • Refined error handling to make the CLI output clearer for the user

Thanks to the instructor for the thoughtful feedback — it really helped me polish both tasks and see new ways to improve my code. This update makes the project more readable, user‑friendly and maintainable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed This assignment has been reivewed by a mentor and a feedback has been provided

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants