This is a simple To-Do List backend application built using Node.js and Express.js. The API allows users to perform CRUD operations (Create, Read, Update, Delete) on tasks.
- Add new tasks
- View all tasks
- Update existing tasks
- Delete tasks
Make sure you have the following installed:
- Clone this repository:
git clone https://github.com/your-repo/todo-list-backend.git
- Navigate into the project directory:
cd todo-list-backend - Install dependencies:
npm install
- Start the server:
The server will run on
node server.js
http://localhost:3500.
- Method:
POST - Endpoint:
/task - Request Body (JSON):
{ "title": "Buy groceries", "description": "Get milk, eggs, and bread" } - Response:
{ "message": "Task created successfully", "task": { "id": "1", "title": "Buy groceries", "description": "Get milk, eggs, and bread" } } - Description:
- Receives task data.
- Validates if
titleanddescriptionexist. - Stores the task in an array.
- Returns the newly created task.
- Method:
GET - Endpoint:
/task - Response:
{ "items": [ { "id": "1", "title": "Buy groceries", "description": "Get milk, eggs, and bread" } ] } - Description:
- Retrieves all tasks stored in the array.
- Method:
PUT - Endpoint:
/task/:id - Request Body (JSON):
{ "title": "Updated Task", "description": "Updated description" } - Response:
{ "message": "Task updated successfully", "task": { "id": "1", "title": "Updated Task", "description": "Updated description" } } - Description:
- Finds the task by
id. - Updates the
titleanddescription. - Returns the updated task.
- Finds the task by
- Method:
DELETE - Endpoint:
/task/:id - Response:
{ "message": "Task deleted successfully" } - Description:
- Finds the task by
id. - Deletes it from the array.
- Returns a success message.
- Finds the task by
To start the application, run:
node server.jsThe server will be available at http://localhost:3500.
- Connect to a database (e.g., MongoDB, PostgreSQL).
- Implement authentication.
- Add due dates and priority levels for tasks.
This project is open-source. Feel free to modify and improve!