https://github.com/nerdy-nakul/todo-application
This is a backend implementation for a ToDo application with authentication using email, password, and JWT. It includes CRUD operations for ToDo items and uses MongoDB as the database.
https://github.com/nerdy-nakul/todo-application
cookies expressjs js json jwt mongodb mongoose nodejs
Last synced: 3 months ago
JSON representation
This is a backend implementation for a ToDo application with authentication using email, password, and JWT. It includes CRUD operations for ToDo items and uses MongoDB as the database.
- Host: GitHub
- URL: https://github.com/nerdy-nakul/todo-application
- Owner: nerdy-nakul
- Created: 2024-07-07T18:48:19.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-04T09:16:55.000Z (over 1 year ago)
- Last Synced: 2025-08-11T09:33:02.881Z (11 months ago)
- Topics: cookies, expressjs, js, json, jwt, mongodb, mongoose, nodejs
- Language: JavaScript
- Homepage:
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ToDo App Backend
This is a backend implementation for a basic ToDo application with authentication using email, password, and JWT. It includes CRUD operations for ToDo items and uses MongoDB as the database.
## Features
- User authentication (Signup and Login) using JWT
- Create, Read, Update, and Delete (CRUD) operations for ToDo items
- Middleware for protected routes
- MongoDB for data storage
## Technologies Used
- Node.js
- Express.js
- MongoDB (Mongoose)
- JWT (JSON Web Token)
- bcryptjs (for password hashing)
## Prerequisites
Before you begin, ensure you have the following installed on your machine:
- Node.js
- MongoDB
## Getting Started
### Installation
1. **Clone the repository:**
```sh
git clone https://github.com/your-username/todo-app-backend.git
cd todo-app-backend
```
2. **Install dependencies:**
```sh
npm install
```
3. **Set up environment variables:**
Create a `.env` file in the root directory of your project and add the following environment variables:
```env
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
PORT=8000
```
### Running the Application
1. **Start the MongoDB server:**
Ensure your MongoDB server is running. You can start it using the following command (if installed locally) or Can use MongoDB Compass.
```sh
mongod
```
2. **Start the Node.js server:**
```sh
npm start
```
The server will start on the port specified in your `.env` file (default is 8000).
### API Endpoints
The following API endpoints are available:
#### Auth Routes
- **Signup**
```
POST /api/v1/signup
```
Request body:
```json
{
"name":"yourname"
"email": "user@example.com",
"password": "yourpassword"
}
```
- **Login**
```
POST /api/v1/login
```
Request body:
```json
{
"email": "user@example.com",
"password": "yourpassword"
}
```
#### ToDo Routes (Protected)
- **Create ToDo**
```
POST /api/v1/createTodo
```
Request body:
```json
{
"title": "New Todo",
"desc":"New Desc"
}
```
- **Get All ToDos**
```
GET /api/v1/getTodos
```
- **Get ToDo by ID**
```
GET /api/v1/getTodos/:id
```
- **Update ToDo**
```
PUT /api/v1/updateTodo/:id
```
Request body:
```json
{
"title": "Updated Todo",
"desc":"updated desc"
}
```
- **Delete ToDo**
```
DELETE /api/v1/deleteTodo/:id
```
### Middleware
The `Auth` middleware is used to protect routes that require authentication. It verifies the JWT token and attaches the user payload to the request object.
### License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.