Given an app.js
file and an empty database file todoApplication.db
.
Create a table with the name todo
with the following columns,
Todo Table
Column | Type |
---|---|
id | INTEGER |
todo | TEXT |
priority | TEXT |
status | TEXT |
and write APIs to perform operations on the table todo
,
- Replace the spaces in URL with
%20
. - Possible values for
priority
areHIGH
,MEDIUM
, andLOW
. - Possible values for
status
areTO DO
,IN PROGRESS
, andDONE
.
-
Scenario 1
-
Sample API
/todos/?status=TO%20DO
-
Description:
Returns a list of all todos whose status is 'TO DO'
-
Response
[ { id: 1, todo: "Watch Movie", priority: "LOW", status: "TO DO" }, ... ]
-
-
Scenario 2
-
Sample API
/todos/?priority=HIGH
-
Description:
Returns a list of all todos whose priority is 'HIGH'
-
Response
[ { id: 2, todo: "Learn Node JS", priority: "HIGH", status: "IN PROGRESS" }, ... ]
-
-
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", status: "IN PROGRESS" }, ... ]
-
-
Scenario 4
-
Sample API
/todos/?search_q=Play
-
Description:
Returns a list of all todos whose todo contains 'Play' text
-
Response
[ { id: 4, todo: "Play volleyball", priority: "MEDIUM", status: "DONE" }, ... ]
-
Returns a specific todo based on the todo ID
{
id: 2,
todo: "Learn JavaScript",
priority: "HIGH",
status: "DONE"
}
Create a todo in the todo table,
{
"id": 10,
"todo": "Finalize event theme",
"priority": "LOW",
"status": "TO DO"
}
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": "Some task" }
-
Response
Todo Updated
-
Deletes a todo from the todo table based on the todo ID
Todo Deleted
Use npm install
to install the packages.
Export the express instance using the default export syntax.
Use Common JS module syntax.