Create an app.js file and connect it with mongodb Database.
Write APIs to perform operations on the table todo, with the following columns,
Todo Table
| Column | Type |
|---|---|
| id | INTEGER |
| todo | TEXT |
| category | TEXT |
| priority | TEXT |
| status | TEXT |
| due_date | DATE |
- Replace the spaces in URL with
%20. - Possible values for
priorityareHIGH,MEDIUM, andLOW. - Possible values for
statusareTO DO,IN PROGRESS, andDONE. - Possible values for
categoryareWORK,HOME, andLEARNING. - Use the format
yyyy-MM-ddfor formating with date-fnsformatfunction.- The user may request with due date value as
2021-1-21, format the date to2021-01-21and perform Create, Read, Update operations on the database.
- The user may request with due date value as
Use proper methodology to make a scalable backend and database.
-
Invalid Status
- Response
- Status code
400 - Body
Invalid Todo Status
- Status code
- Response
-
Invalid Priority
- Response
- Status code
400 - Body
Invalid Todo Priority
- Status code
- Response
-
Invalid Category
- Response
- Status code
400 - Body
Invalid Todo Category
- Status code
- Response
-
Invalid Due Date
- Response
- Status code
400 - Body
Invalid Due Date
- Status code
- Response
-
Scenario 1
-
Sample API
/todos/?status=TO%20DO -
Description:
Returns a list of all todos whose status is 'TO DO'
-
Response
[ { "id": 2, "todo": "Buy a Car", "priority": "Medium", "category": "WORK", "status": "TO DO", "dueDate": "2021-09-22" }, ... ]
-
-
Scenario 2
-
Sample API
/todos/?priority=HIGH -
Description:
Returns a list of all todos whose priority is 'HIGH'
-
Response
[ { "id": 1, "todo": "Learn Node JS", "priority": "HIGH", "status": "IN PROGRESS", "category": "LEARNING", "status": "IN PROGRESS", "dueDate": "2021-04-04" } ]
-
-
Scenario 3
-
Sample API
/todos/?priority=HIGH&status=IN%20PROGRESS -
Description:
Returns a list of all todos whose priority is 'HIGH' and status is 'IN PROGRESS'
-
Response
[ { "id": 2, "todo": "Learn Node JS", "priority": "HIGH", "category": "LEARNING", "status": "IN PROGRESS", "dueDate": "2021-02-22" }, ... ]
-
-
Scenario 4
-
Sample API
/todos/?search_q=Buy -
Description:
Returns a list of all todos whose todo contains 'Buy' text
-
Response
[ { "id": 2, "todo": "Buy a Car", "priority": "MEDIUM", "status":"TO DO" "category": "HOME", "dueDate": "2021-09-22" } ]
-
-
Scenario 5
-
Sample API
/todos/?category=WORK&status=DONE -
Description:
Returns a list of all todos whose category is 'WORK' and status is 'DONE'
-
Response
[ { "id": 4, "todo": "Fix the bug", "priority": "MEDIUM", "status": "TO DO", "category": "WORK", "dueDate": "2021-01-12" } ]
-
-
Scenario 6
-
Sample API
/todos/?category=HOME -
Description:
Returns a list of all todos whose category is 'HOME'
-
Response
[ { "id": 2, "todo": "Buy a Car", "priority": "MEDIUM", "status": "TO DO", "category": "HOME", "dueDate": "2021-09-22" }, ... ]
-
-
Scenario 7
-
Sample API
/todos/?category=LEARNING&priority=HIGH -
Description:
Returns a list of all todos whose category is 'LEARNING' and priority is 'HIGH'
-
Response
[ { "id": 1, "todo": "Learn Node JS", "priority": "HIGH", "status": "IN PROGRESS", "category": "LEARNING", "dueDate": "2021-04-04" } ]
-
Returns a specific todo based on the todo ID
{
"id": 1,
"todo": "Learn Node JS",
"priority": "HIGH",
"status": "IN PROGRESS",
"category": "LEARNING",
"dueDate": "2021-04-04"
}
Returns a list of all todos with a specific due date in the query parameter /agenda/?date=2021-02-22
[
{
"id": 3,
"todo": "Clean the garden",
"priority": "LOW",
"status": "TO DO",
"category": "HOME",
"dueDate": "2021-02-22"
}
]
Create a todo in the todo table,
{
"id": 6,
"todo": "Finalize event theme",
"priority": "LOW",
"status": "TO DO",
"category": "HOME",
"dueDate": "2021-02-22"
}
Todo Successfully Added
Updates the details of a specific todo based on the todo ID
-
Scenario 1
-
Request
{ "status": "DONE" } -
Response
Status Updated
-
-
Scenario 2
-
Request
{ "priority": "HIGH" } -
Response
Priority Updated
-
-
Scenario 3
-
Request
{ "todo": "Clean the garden" } -
Response
Todo Updated
-
-
Scenario 4
-
Request
{ "category": "LEARNING" } -
Response
Category Updated
-
-
Scenario 5
-
Request
{ "dueDate": "2021-01-12" } -
Response
Due Date Updated
-
Deletes a todo from the todo table based on the todo ID
Todo Deleted
Use npm init to initialize a javascript project.
Use npm install to install dependencies.
Use Express.js to make the backend & mongoose for database connection
Bonus points for implementing a fully functional authentication routes.