A simple task manager backend implemented in node JS.
npm install
node app.js
The REST API to the example app is described below.
GET /tasks/
curl -i -H 'Accept: application/json' http://localhost:7000/tasks/
[
{
"id": 1,
"task": "Help teacher in chores",
"priority": "high",
"completed": "false",
"created": "Fri Apr 21 2023",
"updated": "Fri Apr 21 2023"
},
{
"id": 2,
"task": "Help dad in chores",
"priority": "medium",
"completed": "false",
"created": "Fri Apr 21 2023",
"updated": "Fri Apr 21 2023"
},
{
"id": 3,
"task": "Help mom in chores",
"priority": "low",
"completed": "false",
"created": "Fri Apr 21 2023",
"updated": "Fri Apr 21 2023"
}
]
GET /tasks?isCompleted={true or false}&sortDate={asec or desc}
curl -i -H 'Accept: application/json' http://localhost:7000/tasks?isCompleted=false&sortDate=desc
[
{
"id": 3,
"task": "Help mom in chores",
"priority": "low",
"completed": "false",
"created": "Fri Apr 21 2023",
"updated": "Fri Apr 24 2023"
},
{
"id": 2,
"task": "Help dad in chores",
"priority": "medium",
"completed": "false",
"created": "Fri Apr 21 2023",
"updated": "Fri Apr 23 2023"
},
{
"id": 1,
"task": "Help teacher in chores",
"priority": "high",
"completed": "false",
"created": "Fri Apr 21 2023",
"updated": "Fri Apr 22 2023"
}
]
GET /tasks/priority/:priority
curl -i -H 'Accept: application/json' http://localhost:7000/tasks/priority/low
[
{
"id": 3,
"task": "Help mom in chores",
"priority": "low",
"completed": "false",
"created": "Fri Apr 21 2023",
"updated": "Fri Apr 24 2023"
}
]
GET /tasks/:id
curl -i -H 'Accept: application/json' http://localhost:7000/tasks/4
{
"id": 3,
"task": "Help mom in chores",
"priority": "low",
"completed": "false",
"created": "Fri Apr 21 2023",
"updated": "Fri Apr 24 2023"
}
POST /tasks/
curl -i -H 'Accept: application/json' http://localhost:7000/tasks/
Body: {
"task": "String",
"priority": "String" // low,medium,high
}
Example Body: {
"task": "Help mom in chores",
"priority": "low"
}
{
"success": true,
"message": "task successfully created",
"tasks": [
{
"id": 1,
"task": "Help teacher in chores",
"priority": "high",
"completed": "false",
"created": "Fri Apr 21 2023",
"updated": "Fri Apr 22 2023"
},
{
"id": 2,
"task": "Help dad in chores",
"priority": "medium",
"completed": "false",
"created": "Fri Apr 21 2023",
"updated": "Fri Apr 23 2023"
},
{
"id": 3,
"task": "Help mom in chores",
"priority": "low",
"completed": "false",
"created": "Fri Apr 21 2023",
"updated": "Fri Apr 24 2023"
},
{
"id": 4,
"task": "Help uncle in chores",
"priority": "low",
"completed": "false",
"created": "Fri Apr 21 2023",
"updated": "Fri Apr 21 2023"
}
]
}
PUT /tasks/:id
curl -i -H 'Accept: application/json' http://localhost:7000/tasks/4
body: {
"task": "String",
"priority": "String", // low,medium,high
"completed": "String" // true or false
}
example body: {
"task": "Help uncle in chores",
"priority": "low",
"completed": "true"
}
{
"id": 4,
"task": "Help uncle in chores",
"priority": "low",
"completed": "true",
"created": "Fri Apr 21 2023",
"updated": "Fri Apr 21 2023"
}
DELETE /tasks/:id
curl -i -H 'Accept: application/json' http://localhost:7000/tasks/4
{
"id": 4,
"task": "Help uncle in chores",
"priority": "low",
"completed": "true",
"created": "Fri Apr 21 2023",
"updated": "Fri Apr 21 2023"
}