Go back to projects

TODO Backend API

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

FrameworkExpress.js
Use CaseBackend API
DeploymentRender
TODO Backend API

📋 Overview

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.

✨ Features

  • JWT-based authentication
  • User registration and login
  • CRUD operations for tasks
  • Protected routes with middleware
  • User profile management
  • Password change functionality
  • MongoDB database integration
  • Error handling and validation
  • CORS enabled for frontend integration

🛠️ Technologies Used

Node.jsExpress.jsMongoDBMongooseJWT (jsonwebtoken)bcryptjscorsdotenv

📋 Prerequisites

  • Node.js (v18+)
  • MongoDB Atlas account
  • npm or yarn

🚀 Getting Started

Clone the repository

git clone https://github.com/Ahmed-Alabadla/todo-backend.git
cd todo-backend

Install dependencies

npm install

Run the development server

npm run dev

💡 Usage

Start the server and use the API endpoints for task management. The API provides authentication, task CRUD operations, and user management features.

🚀 Deployment

  1. Create a Render account at render.com
  2. Connect your GitHub repository
  3. Create a new Web Service
  4. Configure environment variables in Render dashboard
  5. Deploy automatically from GitHub

🔐 Environment Variables

VariableDescriptionExample
JWT_SECRETSecret key for JWT token generationyour-super-secret-jwt-key-here
ATLAS_URIMongoDB Atlas connection stringmongodb+srv://username:password@cluster.mongodb.net/database
PORTPort number for the server5000

🛣️ API Routes

TASKS ENDPOINT

MethodRouteDescriptionAuth RequiredAccess
POST/api/tasksCreate a new taskYes-
GET/api/tasksGet all tasks for authenticated userYes-
PUT/api/tasks/:taskIdUpdate a specific taskYes-
DELETE/api/tasks/:taskIdDelete a specific taskYes-

AUTH ENDPOINT

MethodRouteDescriptionAuth RequiredAccess
POST/api/registerRegister a new userNo-
POST/api/loginLogin user and get JWT tokenNo-
PUT/api/change-nameChange user's display nameYes-
PUT/api/change-passwordChange user's passwordYes-

USER ENDPOINT

MethodRouteDescriptionAuth RequiredAccess
GET/api/usersGet all users (admin only)No-
GET/api/profileGet current user profileYes-
DELETE/api/userDelete current user accountYes-