lugenx/ecohabit

Implement Backend Endpoints for User-Specific Habits

Closed this issue · 2 comments

lugenx commented

We need to have endpoints that allow us to add or remove habits from a user's specific list of habits. These endpoints should add or remove ObjectIds from the habits field in a User document. The endpoints should be as follows:

POST /users/:userId/myhabits/:habitId: This endpoint should add the habit with the given habitId to the user's list of habits. The function handling this request should push the habitId to the user's habits array in the database and then save the User document.

DELETE /users/:userId/myhabits/:habitId: This endpoint should remove the habit with the given habitId from the user's list of habits. The function handling this request should pull the habitId from the user's habits array from the database and then save the User document.

Both endpoints need to handle errors appropriately and return suitable responses based on the result of the operation.

@lugenx I can work on this one

lugenx commented

Great, please go ahead 👍