Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion tasks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
| :--------------------------------: | :---------------: |
| [GET /tasks](#get-tasks) | Returns all tasks |
| [GET /tasks/self](#get-tasksself) | Returns all tasks of a user |
| [GET /tasks/paginated](#get-taskspaginated) | Returns all tasks based on the query (paginated) |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to have a paginated path. Is there something else we can do here to make it implicit to handle pagination, e.g using query params?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, i have decided to make that change, and will do that

| [POST /tasks](#post-tasks) | Creates new task |
| [PATCH /tasks/:id](#patch-tasksid) | Updates tasks |
| [GET /tasks/:username](#get-tasksusername) | Returns all tasks of the user |
Expand Down Expand Up @@ -114,6 +115,40 @@ Returns all the completed tasks of user if query `completed=true` is passed, els
- **Content:** `{ 'statusCode': 404, 'error': 'Not Found', 'message': 'User doesn't exist' }`
- **Code:** 500
- **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }`


## **GET /tasks/paginated**

Returns all the tasks which are created after the ```<task_object>``` whose "id" would be passed in the query ```after```. The no. of returned documents is controlled by ```limit```again from the query which will also have a default.

- **Params**
None
- **Query**
_Required:_ limit=[number], after=[string(task id)]
- **Body**
None
- **Headers**
None
- **Cookie**
None
- **Success Response:**
- **Code:** 200
- **Content:**
```
{
tasks : {<task_object>}[],
total : {<task_object>}[] length,
till : <task_object_id>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea!
Should we combine total, till etc under a common field in the result?

If you ask me, I would highly recommend us adopting: https://jsonapi.org/ spec

}
```

- **Error Response:**
- **Code:** 500
- **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }`
- **Code:** 404
- **Content:** `{ 'statusCode': 404, 'error': 'Not Found', 'message': 'limit or after undefined' }`
- **Code:** 500
- **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }`

## **GET /tasks/:username**

Expand Down Expand Up @@ -222,4 +257,4 @@ Returns all tasks of the requested user.
- **Code:** 404
- **Content:** `{ 'statusCode': 404, 'error': 'Not Found', 'message': 'Task doesn't exist' }`
- **Code:** 500
- **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }`
- **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }`