This repository contains the backend implementation of a simple Todo application using Node.js, Express.js, MongoDB, and JWT for authentication.
- User Authentication: Users can sign up and log in securely using JWT authentication.
- Todo Management: Users can create, read, update, and delete todo items.
- Secure Password Storage: User passwords are securely hashed using bcrypt before storing them in the database.
Before running the application, make sure you have the following installed:
- Node.js
- MongoDB
-
Clone the repository:
git clone https://github.com/yourusername/todo-app-backend.git
-
Install dependencies:
cd todo-app-backend npm install
-
Set up environment variables:
Create a
.env
file in the root directory and add the following variables:SECRET_KEY=your_secret_key
-
Run the application:
npm start
POST /signup
: Register a new user.POST /login
: Log in an existing user.
GET /todos
: Retrieve all todo items for the authenticated user.POST /todos/create
: Create a new todo item.PUT /todos/:id
: Update an existing todo item.DELETE /todos/:id
: Delete a todo item.
To sign up a new user, send a POST request to /signup
with the following JSON body:
{
"name": "Your Name",
"email": "[email protected]",
"password": "your_password"
}
To log in an existing user, send a POST request to /login
with the following JSON body:
{
"email": "[email protected]",
"password": "your_password"
}
To perform CRUD operations on todo items, use the corresponding endpoints listed above. Make sure to include the JWT token in the Authorization
header for authenticated requests.
This project is licensed under the MIT License - see the LICENSE file for details.
Special thanks to Express.js and MongoDB for making this project possible.