A RESTful API backend for task management built with Express.js, MongoDB, and JWT authentication.

A robust RESTful API backend for task management applications built with Express.js and MongoDB. Features JWT authentication, CRUD operations for tasks, and user management with secure authentication middleware.
git clone https://github.com/Ahmed-Alabadla/todo-backend.git
cd todo-backendnpm installnpm run devStart the server and use the API endpoints for task management. The API provides authentication, task CRUD operations, and user management features.
| Variable | Description | Example |
|---|---|---|
| JWT_SECRET | Secret key for JWT token generation | your-super-secret-jwt-key-here |
| ATLAS_URI | MongoDB Atlas connection string | mongodb+srv://username:password@cluster.mongodb.net/database |
| PORT | Port number for the server | 5000 |
| Method | Route | Description | Auth Required | Access |
|---|---|---|---|---|
| POST | /api/tasks | Create a new task | Yes | - |
| GET | /api/tasks | Get all tasks for authenticated user | Yes | - |
| PUT | /api/tasks/:taskId | Update a specific task | Yes | - |
| DELETE | /api/tasks/:taskId | Delete a specific task | Yes | - |
| Method | Route | Description | Auth Required | Access |
|---|---|---|---|---|
| POST | /api/register | Register a new user | No | - |
| POST | /api/login | Login user and get JWT token | No | - |
| PUT | /api/change-name | Change user's display name | Yes | - |
| PUT | /api/change-password | Change user's password | Yes | - |
| Method | Route | Description | Auth Required | Access |
|---|---|---|---|---|
| GET | /api/users | Get all users (admin only) | No | - |
| GET | /api/profile | Get current user profile | Yes | - |
| DELETE | /api/user | Delete current user account | Yes | - |