This project is a Task Management API built using Node.js and Express, with MongoDB as the database. It allows users to create, read, update, and delete tasks and includes user authentication and task management features.
- Node.js (v14 or higher)
- npm (v6 or higher)
- MongoDB (local or cloud instance)
- Clone the repository:
git clone https://github.com/123Aiden-G/task-management-api.git
- Navigate to the project directory:
cd task-management-api - Install the dependencies:
npm install
- Create a
.envfile in the root directory and add the following environment variables:PORT=3000 MONGO_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret
To start the server, run:
npm startThe server will start on the port specified in the .env file (default is 3000).
GET /api/tasks- Retrieve all tasksPOST /api/tasks- Create a new taskGET /api/tasks/:id- Retrieve a task by IDPUT /api/tasks/:id- Update a task by IDDELETE /api/tasks/:id- Delete a task by ID
-
Get all tasks:
curl -X GET https://task-management-api-ypwj.onrender.com/api/tasks
-
Create a new task:
curl -X POST https://task-management-api-ypwj.onrender.com/api/tasks -H "Content-Type: application/json" -d '{"title": "New Task", "description": "Task description"}'
-
Get a task by ID:
curl -X GET https://task-management-api-ypwj.onrender.com/api/tasks/1
-
Update a task by ID:
curl -X PUT https://task-management-api-ypwj.onrender.com/api/tasks/1 -H "Content-Type: application/json" -d '{"title": "Updated Task", "description": "Updated description"}'
-
Delete a task by ID:
curl -X DELETE https://task-management-api-ypwj.onrender.com/api/tasks/1
To make it easier to test the API, a Postman collection is provided. Follow these steps to import the collection:
- Open Postman.
- Click on the "Import" button in the top left corner.
- Select the
postmanfolder and choose thetask-management-api.postman_collection.jsonfile. - Click "Open" to import the collection.
This folder contains endpoints related to user authentication and profile management.
POST /api/auth/register- Register a new userPOST /api/auth/login- Log in an existing userDELETE /api/auth/me- Delete the authenticated user's accountPUT /api/auth/recover- Recover the authenticated user's accountPUT /api/auth/me- Update the authenticated user's profile
This folder contains endpoints related to task management.
GET /api/tasks- Retrieve all tasks with optional filters, pagination, and sortingPOST /api/tasks- Create a new taskPUT /api/tasks/:taskId- Update an existing taskDELETE /api/tasks/:taskId- Permanently delete a taskPOST /api/tasks/:taskId/comments- Add a comment to a taskPUT /api/tasks/:taskId/assign- Assign a task to another user
This project is licensed under the MIT License.