deliverables to Canvas: A PDF file that has a link to a github repo of yours
your github repo needs to have a file called index.js with all your answers.
more info about that is available in this PDF file
Objective: Extend the to-do API to include a "priority" field in each to-do item.
1- Update the POST endpoint (/todos) to accept a new field called priority in the request body. The priority should be a string with values like "high", "medium", or "low". If the client doesn’t specify a priority, default it to "medium".
2- Update the GET endpoint (/todos) so that each to-do item in the response includes the priority field.
3- Test the new functionality by creating a new to-do item with different priority values (or without any specified priority) and checking that the priority field shows up correctly when you retrieve all to-do items.
Example Usage
curl -X POST http://localhost:3000/todos -H "Content-Type: application/json" -d '{"task": "Complete Express assignment", "priority": "high"}'
curl http://localhost:3000/todos
Objective: Create a new endpoint that marks all to-do items as completed.
1- Add a PUT endpoint /todos/complete-all that updates all existing to-do items by setting their completed status to true.
2- Test the endpoint by adding some to-do items (with completed: false) and then calling the /todos/complete-all endpoint. Afterward, use the GET /todos endpoint to verify that all items are now marked as completed.
Example Usage
curl -X PUT http://localhost:3000/todos/complete-all
Objective: Add a query parameter to the GET /todos endpoint that allows filtering to-do items based on their completed status.
1- Modify the GET /todos endpoint to accept an optional completed query parameter. If this parameter is provided (as either true or false), filter the returned list to show only items that match the specified completion status.
2- If the completed query parameter is not provided, return the full list of to-do items as usual.
3- Test the new functionality by adding some completed and uncompleted to-do items, then fetching the to-do items with completed=true or completed=false.
Example Usage: