A REST based API to manage tasks or to-do lists. Create tasks and track which ones are completed. Built with Node and a mongoDB back-end.
The API returns JSON-encoded responses and uses standard HTTP response codes, authentication, and verbs.
DO NOT USE IN PRODUCTION
This was built for learning purposes only.
The current version of the API lives at https://hagen-task-manager.herokuapp.com
.
Import the request collection from Postman to get started testing quickly.
The Task Manger API uses bearer authentication. Auth tokens are returned in the response via user creation or login requests.
Task Manager API uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, etc.). Codes in the 5xx range indicate an error with the APIs server.
Some 4xx errors could be handled programmatically include an error code that briefly explains the error reported.
POST /users
name: String
email: String
password: String
age: Number
{
"name": "Mary",
"age": 24,
"email": "mary123@gmail.com",
"password": "Blue12345!"
}
{
"user": {
"age": 0,
"_id": "60219c9f0068570017ad3c63",
"name": "Mary",
"email": "mary123@gmail.com",
"createdAt": "2021-02-08T20:18:39.048Z",
"updatedAt": "2021-02-08T20:18:39.104Z",
"__v": 1
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDIxOWM5ZjAwNjg1NzAwMTdhZDNjNjMiLCJpYXQiOjE2MTI4MTU1MTl9.frb2_uzXnFRbDAx_glsF6lO2P2CIZW5yRfh-tM1VRdw"
}
POST /users/login
email: String
password: String
{
"email": "mary123@gmail.com",
"password": "Blue12345!"
}
{
"user": {
"age": 0,
"_id": "60219c9f0068570017ad3c63",
"name": "Mary",
"email": "mary123@gmail.com",
"createdAt": "2021-02-08T20:18:39.048Z",
"updatedAt": "2021-02-08T21:38:17.334Z",
"__v": 2
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDIxOWM5ZjAwNjg1NzAwMTdhZDNjNjMiLCJpYXQiOjE2MTI4MjAyOTd9.TfptG9B-D75AxCZjvKAPqPX3vRSOTyLWD8Quv6teid0"
}
Logs the user out of their current session.
POST /users/logout
Logs the user out of all sessions.
POST /users/logoutAll
GET /users/me
{
"age": 0,
"_id": "6021b0df40556c00175c93aa",
"name": "Mary",
"email": "mary456@mail.com",
"createdAt": "2021-02-08T21:45:03.236Z",
"updatedAt": "2021-02-08T22:12:00.418Z",
"__v": 6
}
PATCH /users/me
name: String
email: String
password: String
age: Number
{
"name": "Mary Joseph",
"age": "24",
"email": "mary456@gmail.com",
"password": "Blue5678!"
}
{
"age": 23,
"_id": "6021b0df40556c00175c93aa",
"name": "Mary",
"email": "mary456@mail.com",
"createdAt": "2021-02-08T21:45:03.236Z",
"updatedAt": "2021-02-09T18:01:06.270Z",
"__v": 8
}
DELETE /users/me
{
"age": 24,
"_id": "6021b0df40556c00175c93aa",
"name": "Mary Joseph",
"email": "mary456@gmail.com",
"createdAt": "2021-02-08T21:45:03.236Z",
"updatedAt": "2021-02-09T19:46:46.189Z",
"__v": 10
}
POST /tasks
description: String
completed: Boolean
{
"description": "Take out the trash"
}
{
"completed": false,
"_id": "6022f1fbebaf0800170052fc",
"description": "Take out the trash",
"owner": "6022e917ebaf0800170052f9",
"createdAt": "2021-02-09T20:35:07.653Z",
"updatedAt": "2021-02-09T20:35:07.653Z",
"__v": 0
}
GET /tasks
/tasks?completed=true
/tasks?limit=10&skip=20
/tasks?sortBy=createdAt:desc
[
{
"completed": false,
"_id": "6022f1fbebaf0800170052fc",
"description": "Take out the trash",
"owner": "6022e917ebaf0800170052f9",
"createdAt": "2021-02-09T20:35:07.653Z",
"updatedAt": "2021-02-09T20:35:07.653Z",
"__v": 0
},
{
"completed": false,
"_id": "6022f773ebaf0800170052fe",
"description": "Wash the dishes",
"owner": "6022e917ebaf0800170052f9",
"createdAt": "2021-02-09T20:58:27.247Z",
"updatedAt": "2021-02-09T20:58:27.247Z",
"__v": 0
}
]
GET /tasks/:id
PATCH /tasks/:id
description: String
completed: Boolean
{
"completed": "true"
}
{
"completed": true,
"_id": "6022f1fbebaf0800170052fc",
"description": "Take out the trash",
"owner": "6022e917ebaf0800170052f9",
"createdAt": "2021-02-09T20:35:07.653Z",
"updatedAt": "2021-02-09T21:24:50.803Z",
"__v": 0
}
DELETE /tasks/:id
{
"completed": false,
"_id": "6022f773ebaf0800170052fe",
"description": "Wash the dishes",
"owner": "6022e917ebaf0800170052f9",
"createdAt": "2021-02-09T20:58:27.247Z",
"updatedAt": "2021-02-09T20:58:27.247Z",
"__v": 0
}
Special thanks to Andrew Mead