This is a RESTful API for a Todo Application built using Express and PostgreSQL. Below are the API endpoints available for managing tasks, categories, users, and statuses.
For simplicity, this API does not include authentication. You can manage users through the users
endpoint.
- URL:
/categories
- Method:
POST
- Request Body:
{ "categoryName": "Work" }
- Response:
{ "category_id": 1, "category_name": "Work" }
- URL:
/categories
- Method:
GET
- Response:
[ { "category_id": 1, "category_name": "Work" }, { "category_id": 2, "category_name": "Personal" } ]
- URL:
/categories/{id}
- Method:
DELETE
- Response:
[ {"category delete successfully"} ]
- URL:
/users
- Method:
POST
- Request Body:
{ "username": "JohnDoe", "email": "[email protected]" }
- Response:
{ "user_id": 1, "username": "JohnDoe", "email": "[email protected]" }
- URL:
/users
- Method:
GET
- Response:
[ { "user_id": 1, "username": "JohnDoe", "email": "[email protected]" }, { "user_id": 2, "username": "JaneDoe", "email": "[email protected]" } ]
- URL:
/statuses
- Method:
POST
- Request Body:
{ "statusName": "Pending" }
- Response:
{ "status_id": 1, "status_name": "Pending" }
- URL:
/statuses
- Method:
GET
- Response:
[ { "status_id": 1, "status_name": "Pending" }, { "status_id": 2, "status_name": "Completed" } ]
- URL:
/tasks
- Method:
POST
- Request Body:
{ "taskTitle": "Finish project report", "taskDescription": "Complete the report by the end of the week.", "userId": 1, "categoryId": 1, "statusId": 1, "dueDate": "2024-10-20" }
- Response:
{ "task_id": 1, "task_title": "Finish project report", "task_description": "Complete the report by the end of the week.", "user_id": 1, "category_id": 1, "status_id": 1, "due_date": "2024-10-20" }
- URL:
/tasks
- Method:
GET
- Response:
[ { "task_id": 1, "task_title": "Finish project report", "task_description": "Complete the report by the end of the week.", "due_date": "2024-10-20", "username": "JohnDoe", "category_name": "Work", "status_name": "Pending" } ]
- URL:
/tasks/:id/status
- Method:
PUT
- Request Body:
{ "statusId": 2 }
- Response:
{ "task_id": 1, "task_title": "Finish project report", "task_description": "Complete the report by the end of the week.", "user_id": 1, "category_id": 1, "status_id": 2, "due_date": "2024-10-20" }
- URL:
/tasks/:id
- Method:
DELETE
- Response:
{ "message": "Task deleted successfully" }
- Replace
:id
with the actual ID of the task you wish to update or delete. - Ensure you have created the necessary categories, users, and statuses before creating tasks to avoid foreign key constraint errors.
- Ensure PostgreSQL is running.
- Run
npm install
to install dependencies. - Start the server with
npm start
.
This README provides a comprehensive overview of the Todo App API and the Postman requests you can use to interact with it. Adjust the details as necessary based on your project structure and requirements.