Task man is a REST api to keep track of your day to day task. Users can login to taskman and perform various operations such as:
- Creating a task with "description" and "completed" information of the task.
- Updating a task.
- Deleting a task.
- Setting up a user profile picture.
API endpoint: https://recks-task-man.herokuapp.com/
{url} : recks-task-man.herokuapp.com
Registers a new user in the database/Logs in a user and returns the user information, along with the web token.
Title | Create User | Login User |
---|---|---|
URL | /users |
/users/login |
Method | POST | POST |
URL Parameters | None | None |
Data Parameters | Body: { "name": "John Doe", "email": "johndoe@gmail.com", "age": 21, "password" : "newuser1289" } |
Body: { "email": "johndoe@gmail.com", "password" : "newuser1289" } |
Success Response | Code: 201 Content: { "user": { "name": "John Doe", "email": "johndoe@gmail.com", "age": 21, "_id": "619fb34831490c08facc98d7", "createdAt": "2021-11-25T16:01:12.944Z", "updatedAt": "2021-11-25T16:01:13.105Z", "__v": 1 }, "token": "eyJhb..." } |
Code: 200 Content: { "user": { "name": "John Doe", "email": "johndoe@gmail.com", "age": 21, "_id": "619fb34831490c08facc98d7", "createdAt": "2021-11-25T16:01:12.944Z", "updatedAt": "2021-11-25T16:01:13.105Z", "__v": 1 }, "token": "eyJhb..." } |
Error Response | Code: 400 | Code: 400 |
Sample Call | const user = { name: 'John Doe', email: 'johndoe@gmail.com', age: 21, password : 'newuser1289' }; axios.post('https://{url}/users', user) .then((response) =>{ console.log(response) }) .catch((error) => { console.error('There was an error!', error); }); |
const user = { email: 'johndoe@gmail.com', password: 'newuser1289' }; axios.post('https://{url}/users/login', user) .then((response) =>{ console.log(response) }) .catch((error) => { console.error('There was an error!', error); }); |
Creates a new task and store it in the database and returns the task information
Title | Create task |
---|---|
URL | /tasks |
Method | POST |
URL Parameters | None |
Data Parameters | Body: { description : [string], completed : [boolean], } Example: { "description": "Cook food", "completed": "false", } |
Success Response | Code: 201 Content: { "description": "Cook food", "completed": false, "owner": "619...", "_id": "61a...", "createdAt": "2021-11-26T03:34:15.909Z", "updatedAt": "2021-11-26T03:34:15.909Z", "__v": 0 } |
Error Response | Code: 400 |
Sample Call | const task = { description: 'Cook food', completed: false, }; axios.post('https://{url}/tasks', task) .then((response) =>{ console.log(response) }) .catch((error) => { console.error('There was an error!', error); }); |
Logout user(s)
Title | Logout user from one device | Logout user from all devices |
---|---|---|
URL | /users/logout |
/users/logoutAll |
Method | POST | POST |
URL Parameters | None | None |
Data Parameters | None | None |
Success Response | Code: 200 | Code: 200 |
Error Response | Code: 401 UNAUTHORIZED Content: { error: "Please authenticate." } |
Code: 401 UNAUTHORIZED Content: { error: "Please authenticate." } |
Sample Call | axios.post('https://{url}/users/logout') .then((response) =>{ console.log(response) }) .catch((error) => { console.error('There was an error!', error); }); |
axios.post('https://{url}/users/logoutAll') .then((response) =>{ console.log(response) }) .catch((error) => { console.error('There was an error!', error); }); |
Title | Read user profile |
---|---|
URL | /users/me |
Method | GET |
URL Parameters | None |
Data Parameters | None |
Success Response | Code: 200 Content:* { "_id": "619f...", "name": "John Doe", "email": "johndoe@gmail.com", "age": 21, "createdAt": "2021-11-25T16:01:12.944Z", "updatedAt": "2021-11-26T14:03:32.990Z", "__v": 8 } |
Error Response | Code: 401 UNAUTHORIZED Content: { error: "Please authenticate." } |
Sample Call | axios.get('https://{url}/users/me') .then((response) =>{ console.log(response) }) .catch((error) => { console.error('There was an error!', error); }); |
Returns array/single task(s)
Title | Read all tasks | Read a tasks by its id |
---|---|---|
URL | /tasks |
/tasks/:id example: /tasks/61a05618849d63b275c7d036 |
Method | GET | GET |
URL Parameters | Optional completed=[boolean] example: completed=true (it will only return the completed tasks) limit=[integer] example: limit=5 (it will only return 5 tasks) skip=[integer] example: skip=5 (it will skip the first 5 tasks and fetch the next 5) sort=[string] example: sort=createdAt:asc (or desc) (it will sort the tasks depending on the time, when it was created) |
None |
Data Parameters | None | None |
Success Response | Code: 200 Content:* [ { "_id": "61a...", "description": "Cook food", "completed": false, "owner": "619...", "createdAt": "2021-11-26T03:35:52.880Z", "updatedAt": "2021-11-26T03:35:52.880Z", "__v": 0 }, { "_id": "61a...", "description": "Make notes", "completed": true, "owner": "619...", "createdAt": "2021-11-27T02:23:47.155Z", "updatedAt": "2021-11-27T02:23:47.155Z", "__v": 0 } ] |
Code: 200 Content: { "_id": "61a05618849d63b275c7d036", "description": "Cook food", "completed": false, "owner": "619f...", "createdAt": "2021-11-26T03:35:52.880Z", "updatedAt": "2021-11-26T03:35:52.880Z", "__v": 0 } |
Error Response | Code: 401 UNAUTHORIZED Content: { error: "Please authenticate." } |
Code: 401 UNAUTHORIZED Content: { error: "Please authenticate." } OR Code: 404 NOT FOUND OR Code: 500 INTERNAL SERVER ERROR |
Sample Call | axios.get('https://{url}/tasks?completed=true') .then((response) =>{ console.log(response) }) .catch((error) => { console.error('There was an error!', error); }); |
axios.get('https://{url}/tasks/61a05618849d63b275c7d036') .then((response) =>{ console.log(response) }) .catch((error) => { console.error('There was an error!', error); }); |
Title | Update user profile | Update a tasks by its id |
---|---|---|
URL | /users/me |
/tasks/:id example: /tasks/61a196b39421d590f8713f74 |
Method | PATCH | PATCH |
URL Parameters | None | None |
Data Parameters | Body: { name : [string], email : [string], password : [alphanumeric], age:[positive integer] } Fields are optional Example: { "name": "Johnny Doe", "age": 50, } |
Body: { description : [string], completed : [boolean], } Fields are optional Example: { "description": "Go shopping", "completed": "false", } |
Success Response | Code: 200 Content:* { "_id": "619f...", "name": "Johnny Doe", "email": "johndoe@gmail.com", "age": 50, "createdAt": "2021-11-25T16:01:12.944Z", "updatedAt": "2021-11-27T03:09:37.513Z", "__v": 11 } |
Code: 200 Content: { "_id": "61a196b39421d590f8713f74", "description": "Go shopping", "completed": false, "owner": "619f...", "createdAt": "2021-11-27T02:23:47.155Z", "updatedAt": "2021-11-27T03:15:02.366Z", "__v": 0 } |
Error Response | Code: 401 UNAUTHORIZED Content: { error: "Please authenticate." } |
Code: 401 UNAUTHORIZED Content: { error: "Please authenticate." } |
Sample Call | const user = { name: 'Johnny Doe', age: 50, }; axios.patch('https://{url}/users/me', user) .then((response) =>{ console.log(response) }) .catch((error) => { console.error('There was an error!', error); }); |
const task = { description: 'Go shopping', completed: false, }; axios.patch('https://{url}//tasks/61a196b39421d590f8713f74', task) .then((response) =>{ console.log(response) }) .catch((error) => { console.error('There was an error!', error); }); |
Title | Delete user profile | Delete a tasks by its id |
---|---|---|
URL | /users/me |
/tasks/:id example: /tasks/61a1a76a202dda493d83ca4c |
Method | DELETE | DELETE |
URL Parameters | None | None |
Data Parameters | None | None |
Success Response | Code: 200 Content: { "_id": "619f...", "name": "Johnny Doe", "email": "johndoe@gmail.com", "age": 50, "createdAt": "2021-11-25T16:01:12.944Z", "updatedAt": "2021-11-27T03:30:13.651Z", "__v": 12 } |
Code: 200 Content: { "_id": "61a196b39421d590f8713f74", "description": "Go shopping", "completed": false, "owner": "619f...", "createdAt": "2021-11-27T02:23:47.155Z", "updatedAt": "2021-11-27T03:15:02.366Z", "__v": 0 } |
Error Response | Code: 401 UNAUTHORIZED Content: { error: "Please authenticate." } |
Code: 401 UNAUTHORIZED Content: { error: "Please authenticate." } |
Sample Call | axios.delete('https://{url}/users/me') .then((response) =>{ console.log(response) }) .catch((error) => { console.error('There was an error!', error); }); ``` | axios.delete('https://{url}//tasks/61a1a76a202dda493d83ca4c') .then((response) =>{ console.log(response) }) .catch((error) => { console.error('There was an error!', error); }); |
Title | Set/update user profile image | Delete user profile image | Get profile image |
---|---|---|---|
URL | users/me/avatar |
users/me/avatar |
users/:id/avatar example: users/61a1a762202dda493d83ca46/avatar |
Method | POST | DELETE | GET |
URL Parameters | None | None | None |
Data Parameters | Body:Image File 1. File should be of .jpg, .jpeg or .png format. 2. File size should be of <=1MB. Headers { 'Content-Type': 'multipart/form-data' } |
None | None |
Success Response | Code: 200 | Code: 200 | Code: 200 Body Image file |
Error Response | Code: 401 UNAUTHORIZED Content: { error: "Please authenticate." } |
Code: 401 UNAUTHORIZED Content: { error: "Please authenticate." } |
Code: 404 NOT FOUND |
Sample Call | var formData = new FormData(); var imagefile = document.querySelector('#file'); formData.append("image", imagefile.files[0]); axios.post('users/me/avatar', formData, { headers: { 'Content-Type': 'multipart/form-data' } }) |
axios.delete('https://{url}/users/me/avatar') .then((response) =>{ console.log(response) }) .catch((error) => { console.error('There was an error!', error); }); |