-
Notifications
You must be signed in to change notification settings - Fork 49
API contract for Todo app #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
01a1f6b
docs: todo-backend api contract
VaibhavSingh8 f54a5a3
docs: fixed few issues
VaibhavSingh8 ecbcadf
docs: fixed response structure
VaibhavSingh8 9470ce0
Update README.md
VaibhavSingh8 1f191f9
docs: fixed response structure and task object fields
VaibhavSingh8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,312 @@ | ||
| # Todo Backend | ||
|
|
||
| #### Task Object: | ||
|
VaibhavSingh8 marked this conversation as resolved.
|
||
|
|
||
| ``` | ||
| { | ||
| id: <ObjectId> | ||
| taskId: <string> | ||
| title: <string> | ||
| description: <string> | null | ||
| priority: LOW | MEDIUM | HIGH | ||
| status: TODO | IN_PROGRESS | DONE | ||
| assignee: { | ||
| id: <string> | ||
| name: <string> | ||
| } | null | ||
| labels: [ | ||
| { | ||
| name: <string> | ||
| color: <string> | ||
| createdAt: <datetime> | null | ||
| updatedAt: <datetime> | null | ||
| createdBy: { | ||
| id: <string> | ||
| name: <string> | ||
| } | null | ||
| updatedBy: { | ||
| id: <string> | ||
| name: <string> | ||
| } | null | ||
| } | ||
| ] | ||
| isAcknowledged: <boolean> | ||
| isDeleted: <boolean> | ||
| deferredDetails: { | ||
| deferredAt: <datetime> | null | ||
| deferredTill: <datetime> | null | ||
| deferredBy: <string> | null | ||
| } | ||
| dueDate: <datetime> | ||
| startDate: <datetime> | null | ||
| createdAt: <datetime> | ||
| updatedAt: <datetime> | null | ||
| createdBy: <string> | ||
| updatedBy: <string> | null | ||
| } | ||
| ``` | ||
|
|
||
| #### DeferredDetails Object: | ||
|
|
||
| ``` | ||
| { | ||
| deferredDate: <datetime> | null | ||
| deferredTill: <datetime> | null | ||
| deferredBy: <string> | null | ||
| } | ||
| ``` | ||
|
|
||
| ## **Requests** | ||
|
|
||
| | Route | Description | | ||
| | :---------------------------: | :------------------------------: | | ||
| | [GET /v1/tasks](#get-tasks) | Return all tasks with pagination | | ||
| | [POST /v1/tasks](#post-tasks) | Creates new task | | ||
| | [GET /v1/health](#get-health) | Health check endpoint | | ||
|
|
||
|
VaibhavSingh8 marked this conversation as resolved.
|
||
| ## **GET /v1/tasks** | ||
|
|
||
| Return all tasks with pagination support | ||
|
|
||
| - **Params** | ||
| None | ||
| - **Query** | ||
|
|
||
| - Optional: `page=[integer]` (Page number for pagination, default: 1) | ||
| - Optional: `limit=[integer]` (Number of items per page, default: from Settings) | ||
|
|
||
| - **Success Response:** | ||
|
|
||
| - **Code:** 200 | ||
| - **Content:** | ||
| ```json | ||
|
iamitprakash marked this conversation as resolved.
|
||
| { | ||
| "statusCode": 200, | ||
| "sucessMessage": "Tasks retrieved successfully", | ||
| "data": [ | ||
| { | ||
| "id": "<string>", | ||
| "taskId": "<string>", | ||
| "title": "<string>", | ||
| "description": "<string> | null", | ||
| "priority": "LOW | MEDIUM | HIGH", | ||
| "status": "TODO | IN_PROGRESS | DONE", | ||
| "assignee": { | ||
| "id": "<string>", | ||
| "name": "<string>" | ||
| } | null, | ||
| "isAcknowledged": "<boolean>", | ||
| "labels": [ | ||
| { | ||
| "name": "<string>", | ||
| "color": "<string>", | ||
| "createdAt": "<datetime> | null", | ||
| "updatedAt": "<datetime> | null", | ||
| "createdBy": { | ||
| "id": "<string>", | ||
| "name": "<string>" | ||
| } | null, | ||
| "updatedBy": { | ||
| "id": "<string>", | ||
| "name": "<string>" | ||
| } | null | ||
| } | ||
| ], | ||
| "startDate": "<datetime> | null", | ||
| "dueDate": "<datetime> | null", | ||
| "createdAt": "<datetime>", | ||
| "updatedAt": "<datetime> | null", | ||
| "createdBy": { | ||
| "id": "<string>", | ||
| "name": "<string>" | ||
| }, | ||
| "updatedBy": { | ||
| "id": "<string>", | ||
| "name": "<string>" | ||
| } | null | ||
| } | ||
| ], | ||
| "links": { | ||
| "next": "<string> | null", | ||
| "prev": "<string> | null" | ||
| }, | ||
| "count":"number" | ||
| } | ||
| ``` | ||
|
|
||
| - **Error Response:** | ||
|
|
||
| - **Code:** 400 | ||
| - **Content:** | ||
|
|
||
| ```json | ||
| { | ||
| "status": "validation_failed", | ||
| "statusCode": 400, | ||
| "errorMessage": "Validation Error", | ||
| "errors": [ | ||
| { | ||
| "field": "<string>", | ||
| "message": "<string>" | ||
| } | ||
| <!-- Example { | ||
| "field": "page", | ||
| "message": "page must be greater than or equal to 1" | ||
| } --> | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| - **Code:** 500 | ||
| - **Content:** | ||
|
|
||
| ```json | ||
| { | ||
| "statusCode": 500, | ||
| "errorMessage": "An unexpected error occurred", | ||
| "errors": [ | ||
| { | ||
| "detail": "Internal server error" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ## **POST /v1/tasks** | ||
|
|
||
| Creates a new task | ||
|
|
||
| - **Params** | ||
| None | ||
| - **Body** | ||
|
|
||
| ```json | ||
| { | ||
| "title": "<string>", | ||
| "description": "<string> | null", | ||
| "priority": "LOW | MEDIUM | HIGH", | ||
| "status": "TODO | IN_PROGRESS | DONE", | ||
| "assignee": "<string> | null", | ||
| "labels": ["<ObjectId>"], | ||
| "dueDate": "<datetime>" | ||
| } | ||
| ``` | ||
|
|
||
| - **Success Response:** | ||
|
|
||
| - **Code:** 201 | ||
| - **Content:** | ||
| ```json | ||
| { | ||
| "statusCode": 201, | ||
| "sucessMessage": "Task created successfully", | ||
| "data": { | ||
| "id": "<string>", | ||
| "taskId": "<string>", // "TASK-1001" | ||
| "title": "<string>", | ||
| "description": "<string> | null", | ||
| "priority": "LOW | MEDIUM | HIGH", | ||
| "status": "TODO | IN_PROGRESS | DONE", | ||
| "assignee": { | ||
| "id": "<string>", | ||
| "name": "<string>" | ||
| } | null, | ||
| "isAcknowledged": "<boolean>", | ||
| "labels": [ | ||
| { | ||
| "name": "<string>", | ||
| "color": "<string>", | ||
| "createdAt": "<datetime>", | ||
| "updatedAt": null, | ||
| "createdBy": { | ||
| "id": "<string>", | ||
| "name": "<string>" | ||
| }, | ||
| "updatedBy": null | ||
| } | ||
| ], | ||
| "startDate": null, | ||
| "dueDate": "<datetime> | null", | ||
| "createdAt": "<datetime>", | ||
| "updatedAt": null, | ||
| "createdBy": { | ||
| "id": "<string>", | ||
| "name": "<string>" | ||
| }, | ||
| "updatedBy": null | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| - **Error Response:** | ||
| - **Code:** 400 | ||
| - **Content:** | ||
| ```json | ||
| { | ||
| "status": "validation_failed" | ||
| "statusCode": 400, | ||
| "errorMessage": "Validation Error", | ||
| "errors": [ | ||
| { | ||
| "field": "<string>", | ||
| "message": "<string>" | ||
| }, | ||
| <!-- Example { | ||
| "field": "title", | ||
| "message": "This field is required" | ||
| } --> | ||
| ] | ||
| } | ||
| ``` | ||
| - **Code:** 500 | ||
| - **Content:** | ||
| ```json | ||
| { | ||
| "status": "internal_server_error" | ||
| "statusCode": 500, | ||
| "errorMessage": "An unexpected error occurred", | ||
| "errors": [ | ||
| { | ||
| "detail": "Internal server error" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ## **GET /v1/health** | ||
|
|
||
| Health check endpoint | ||
|
|
||
| - **Params** | ||
| None | ||
| - **Query** | ||
| None | ||
|
|
||
| - **Success Response:** | ||
|
|
||
| - **Code:** 200 | ||
| - **Content:** | ||
| ```json | ||
| { | ||
| "status": "healthy" | ||
| } | ||
| ``` | ||
|
|
||
| - **Error Response:** | ||
| - **Code:** 500 | ||
| - **Content:** | ||
| ```json | ||
| { | ||
| "status": "unhealthy" | ||
| } | ||
| ``` | ||
|
|
||
| ## **Error Codes** | ||
|
|
||
| | Status Code | Description | | ||
| | :---------: | :----------------------------: | | ||
| | 200 | Success | | ||
| | 201 | Created | | ||
| | 400 | Bad Request (Validation Error) | | ||
| | 404 | Not Found | | ||
| | 500 | Internal Server Error | | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.