From ea3d5548e58e9677a02415c2bd0ef32ec0be4a24 Mon Sep 17 00:00:00 2001 From: Vinayak Goyal <73058928+ivinayakg@users.noreply.github.com> Date: Sat, 23 Jul 2022 22:37:32 +0530 Subject: [PATCH 1/5] API contract for GET tasks/paginated --- tasks/README.md | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tasks/README.md b/tasks/README.md index b0d3916f..536d8161 100644 --- a/tasks/README.md +++ b/tasks/README.md @@ -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) | | [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 | @@ -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 `````` 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 : {}[], + total : {}[] length, + till : +} +``` + +- **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** @@ -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' }` \ No newline at end of file + - **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }` From 92d66b1c69714a1124e0cf56ea416fb6c86004b0 Mon Sep 17 00:00:00 2001 From: Vinayak Goyal <73058928+ivinayakg@users.noreply.github.com> Date: Sun, 24 Jul 2022 12:37:11 +0530 Subject: [PATCH 2/5] API contract for GET /tasks queried --- tasks/README.md | 53 ++++++++++++++++--------------------------------- 1 file changed, 17 insertions(+), 36 deletions(-) diff --git a/tasks/README.md b/tasks/README.md index 536d8161..f7b82f35 100644 --- a/tasks/README.md +++ b/tasks/README.md @@ -42,7 +42,6 @@ | :--------------------------------: | :---------------: | | [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) | | [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 | @@ -50,12 +49,12 @@ ## **GET /tasks** -Returns all the tasks +Returns all the tasks or Returns all the tasks which are created after the `````` 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** - None + _Required:_ limit=[number], after=[string(task id)] `(Only required for pagination)` - **Body** None - **Headers** @@ -75,6 +74,21 @@ Returns all the tasks ] } ``` + - **Content:** (if queried) +``` +{ + message: 'Queried Tasks returned successfully!', + tasks: [ + {}, + {} + ], + meta: { + total : {}[] length, + till : + }, +} +``` + - **Error Response:** - **Code:** 500 @@ -116,39 +130,6 @@ Returns all the completed tasks of user if query `completed=true` is passed, els - **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 `````` 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 : {}[], - total : {}[] length, - till : -} -``` - -- **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** From 26ce84d9a705b45cff02e21a28158bf39572f880 Mon Sep 17 00:00:00 2001 From: Vinayak Goyal <73058928+ivinayakg@users.noreply.github.com> Date: Tue, 26 Jul 2022 13:43:36 +0530 Subject: [PATCH 3/5] requested changes done --- tasks/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tasks/README.md b/tasks/README.md index f7b82f35..d637e6ac 100644 --- a/tasks/README.md +++ b/tasks/README.md @@ -49,12 +49,12 @@ ## **GET /tasks** -Returns all the tasks or Returns all the tasks which are created after the `````` 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. +Returns all the tasks or Returns all the tasks which are created after the `````` whose "id" would be passed in the query ```offset```. 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)] `(Only required for pagination)` + _Required:_ limit=[number], offset=[string(task id)] `(Only required for pagination)` - **Body** None - **Headers** @@ -83,8 +83,9 @@ Returns all the tasks or Returns all the tasks which are created after the ```} ], meta: { - total : {}[] length, - till : + limit : {}[] length (returned tasks length), + offset : (the id of the task which is the last task in the returned array of tasks), + total : {}[] length (all present at the server) }, } ``` From bd6a8a4c4aa87dbae81bc9e61cac5857f3a3fe89 Mon Sep 17 00:00:00 2001 From: Vinayak Goyal <73058928+ivinayakg@users.noreply.github.com> Date: Thu, 11 Aug 2022 15:03:57 +0530 Subject: [PATCH 4/5] Adding filter by query in the API Note: As the query is growing therefore rather than providing a different result based on wether it is queried or not lets just create a union where every result will have a meta data. --- tasks/README.md | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/tasks/README.md b/tasks/README.md index d637e6ac..79af55c9 100644 --- a/tasks/README.md +++ b/tasks/README.md @@ -50,11 +50,12 @@ ## **GET /tasks** Returns all the tasks or Returns all the tasks which are created after the `````` whose "id" would be passed in the query ```offset```. The no. of returned documents is controlled by ```limit```again from the query which will also have a default. +Extending to that we can also filter them based on the status via passing a query param `status`. - **Params** None - **Query** - _Required:_ limit=[number], offset=[string(task id)] `(Only required for pagination)` + _Required:_ limit=[number], offset=[string(task id)] `(Only required for pagination)`, status=[active | assigned | unAssigned | blocked | completed] `(for filtering based on the status of the tasks)` - **Body** None - **Headers** @@ -66,16 +67,6 @@ Returns all the tasks or Returns all the tasks which are created after the ```}, - {} - ] -} -``` - - **Content:** (if queried) -``` { message: 'Queried Tasks returned successfully!', tasks: [ From 7a3e3f698bdd0ffa131c4c9d90424f25a40a57f4 Mon Sep 17 00:00:00 2001 From: Vinayak Date: Thu, 11 Aug 2022 15:16:04 +0530 Subject: [PATCH 5/5] Revert "requested changes done" This reverts commit 26ce84d9a705b45cff02e21a28158bf39572f880. --- tasks/README.md | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/tasks/README.md b/tasks/README.md index 79af55c9..34b4d132 100644 --- a/tasks/README.md +++ b/tasks/README.md @@ -38,24 +38,23 @@ ## **Requests** -| Route | Description | -| :--------------------------------: | :---------------: | -| [GET /tasks](#get-tasks) | Returns all tasks | -| [GET /tasks/self](#get-tasksself) | Returns all tasks of a user | -| [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 | -| [PATCH /tasks/self/:id](#patch-tasksselfid) | Changes in own task | +| Route | Description | +| :-----------------------------------------: | :---------------------------: | +| [GET /tasks](#get-tasks) | Returns all tasks | +| [GET /tasks/self](#get-tasksself) | Returns all tasks of a user | +| [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 | +| [PATCH /tasks/self/:id](#patch-tasksselfid) | Changes in own task | ## **GET /tasks** -Returns all the tasks or Returns all the tasks which are created after the `````` whose "id" would be passed in the query ```offset```. The no. of returned documents is controlled by ```limit```again from the query which will also have a default. -Extending to that we can also filter them based on the status via passing a query param `status`. +Returns all the tasks or Returns all the tasks which are created after the `` 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], offset=[string(task id)] `(Only required for pagination)`, status=[active | assigned | unAssigned | blocked | completed] `(for filtering based on the status of the tasks)` + _Required:_ limit=[number], after=[string(task id)] `(Only required for pagination)` - **Body** None - **Headers** @@ -74,19 +73,16 @@ Extending to that we can also filter them based on the status via passing a quer {} ], meta: { - limit : {}[] length (returned tasks length), - offset : (the id of the task which is the last task in the returned array of tasks), - total : {}[] length (all present at the server) + total : {}[] length, + till : }, } ``` - - **Error Response:** - **Code:** 500 - **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }` - ## **GET /tasks/self** Returns all the completed tasks of user if query `completed=true` is passed, else returns all the active and blocked tasks of the user. @@ -104,6 +100,7 @@ Returns all the completed tasks of user if query `completed=true` is passed, els - **Success Response:** - **Code:** 200 - **Content:** + ``` [ {}, @@ -121,7 +118,6 @@ 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/:username** @@ -138,6 +134,7 @@ Returns all tasks of the requested user. - **Success Response:** - **Code:** 200 - **Content:** + ``` { message: 'Tasks returned successfully!' @@ -154,7 +151,6 @@ Returns all tasks of the requested user. - **Code:** 500 - **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }` - ## **POST /tasks** - **Params** @@ -207,10 +203,11 @@ Returns all tasks of the requested user. - **Headers** Content-Type: application/json -- **Body** +- **Body** + ``` - { - status: + { + status: percentCompleted: } ``` @@ -219,6 +216,7 @@ Returns all tasks of the requested user. rds-session: `` - **Success Response:** + - **Code**: 200 - **Content:** `{'message': 'Task updated successfully!'}`