Skip to content

Azeem46/postgres-todoapp-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Todo App API

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.

Base URL

http://localhost:3000

Authentication

For simplicity, this API does not include authentication. You can manage users through the users endpoint.

Endpoints

1. Categories

Create a New Category

  • URL: /categories
  • Method: POST
  • Request Body:
    {
      "categoryName": "Work"
    }
  • Response:
    {
      "category_id": 1,
      "category_name": "Work"
    }

Get All Categories

  • URL: /categories
  • Method: GET
  • Response:
    [
      {
        "category_id": 1,
        "category_name": "Work"
      },
      {
        "category_id": 2,
        "category_name": "Personal"
      }
    ]

Delete Categories

  • URL: /categories/{id}
  • Method: DELETE
  • Response:
    [
        {"category delete successfully"}
    ]

2. Users

Create a New User

Get All Users

  • URL: /users
  • Method: GET
  • Response:
    [
      {
        "user_id": 1,
        "username": "JohnDoe",
        "email": "[email protected]"
      },
      {
        "user_id": 2,
        "username": "JaneDoe",
        "email": "[email protected]"
      }
    ]

3. Task Status

Create a New Status

  • URL: /statuses
  • Method: POST
  • Request Body:
    {
      "statusName": "Pending"
    }
  • Response:
    {
      "status_id": 1,
      "status_name": "Pending"
    }

Get All Statuses

  • URL: /statuses
  • Method: GET
  • Response:
    [
      {
        "status_id": 1,
        "status_name": "Pending"
      },
      {
        "status_id": 2,
        "status_name": "Completed"
      }
    ]

4. Tasks

Create a New Task

  • 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"
    }

Get All Tasks

  • 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"
      }
    ]

Update Task Status

  • 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"
    }

Delete a Task

  • URL: /tasks/:id
  • Method: DELETE
  • Response:
    {
      "message": "Task deleted successfully"
    }

Additional Notes

  • 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.

Running the Application

  1. Ensure PostgreSQL is running.
  2. Run npm install to install dependencies.
  3. Start the server with npm start.

Conclusion

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published