A secure Task Management API built with Node.js, Express, MongoDB, and JWT. Features user authentication, task management, and secure cookie-based sessions.
- User Authentication
- Register new account
- Login with JWT
- Secure logout
- Token verification
- User Management
- Change email address
- Update password
- Delete account
- View profile
- Task Management
- Create new tasks
- Update existing tasks
- Delete tasks
- List all tasks
- Mark tasks as completed/pending
-
Clone the repository:
git clone https://github.com/yourusername/task-tracker.git cd task-tracker/backend -
Install dependencies:
npm install
-
Create a
.envfile:MONGO_URI=mongodb://localhost:27017/todo JWT_SECRET=your_jwt_secret NODE_ENV=development PORT=3001
-
Start the server:
npm run dev
curl -X POST http://localhost:3001/api/auth/register \
-H "Content-Type: application/json" \
-d '{"name":"John Doe","email":"john@example.com","password":"secret123"}'curl -X POST http://localhost:3001/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"john@example.com","password":"secret123"}'curl -X POST http://localhost:3001/api/auth/logoutcurl -X GET http://localhost:3001/api/user/get-user \
-H "Authorization: Bearer YOUR_TOKEN"curl -X PUT http://localhost:3001/api/user/change-email \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"newEmail":"newemail@example.com"}'curl -X PUT http://localhost:3001/api/user/change-password \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"oldPassword":"old123","newPassword":"new123"}'curl -X POST http://localhost:3001/api/tasks \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"Complete Project","description":"Finish the API","dueDate":"2024-03-20"}'curl -X GET http://localhost:3001/api/tasks \
-H "Authorization: Bearer YOUR_TOKEN"curl -X PUT http://localhost:3001/api/tasks/TASK_ID \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"status":"completed"}'curl -X DELETE http://localhost:3001/api/tasks/TASK_ID \
-H "Authorization: Bearer YOUR_TOKEN"- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database
- Mongoose - ODM
- JWT - Authentication
- bcrypt - Password hashing
- cookie-parser - Cookie handling
- cors - CORS support
- dotenv - Environment variables
Built by iamdanwi
This project is licensed under the MIT License. See the LICENSE file for details.