A backend REST API for managing tasks using Node.js, Express.js, MongoDB Atlas, and JWT authentication.
Render Live Backend:
https://taskmanager-backend-98x0.onrender.comHealth Check API:
https://taskmanager-backend-98x0.onrender.com/api/healthGitHub Repository:
https://github.com/DOTJORDAN-Rahaf/TaskManager-Backend- User registration and login
- Password hashing using bcryptjs
- JWT token generation
- Authentication middleware
- Role-based authorization
- CRUD APIs for tasks
- Users can manage only their own tasks
- Admin can view all tasks
- MongoDB Atlas cloud database connection
- Render deployment support
- Simple backend home page
- Health check endpoint
- Node.js
- Express.js
- MongoDB Atlas
- Mongoose
- bcryptjs
- jsonwebtoken
- dotenv
- cors
- Postman
- Render
Install dependencies:
npm installCreate a .env file in the root directory:
PORT=8000
MONGO_URI=mongodb+srv://USERNAME:PASSWORD@cluster-url/taskmanager?retryWrites=true&w=majority
JWT_SECRET=your_secret_keyRun the project in development mode:
npm run devOr run it using the start script:
npm startServer runs locally on:
http://localhost:8000Health check locally:
http://localhost:8000/api/healthThe backend is deployed on Render as a Web Service.
Render settings:
Build Command:
npm install
Start Command:
npm startEnvironment variables added on Render:
MONGO_URI
JWT_SECRETNote: PORT is not added manually on Render because Render provides it automatically during deployment.
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Simple backend home page |
| GET | /api/health |
Check if backend is running |
| POST | /api/auth/register |
Register user |
| POST | /api/auth/login |
Login user and get token |
| GET | /api/tasks |
Get user tasks |
| POST | /api/tasks |
Create task |
| PUT | /api/tasks/:id |
Update task |
| DELETE | /api/tasks/:id |
Delete task |
| GET | /api/tasks/admin/all |
Admin view all tasks |
Protected APIs require this header:
Authorization: Bearer TOKEN_HERE{
"message": "Task Manager Backend is running"
}- Passwords are hashed before saving.
- JWT is used for authentication.
- Users can manage only their own tasks.
- Admin can view all tasks.
- MongoDB Atlas is used as the cloud database.
- The backend is deployed publicly using Render.
- The
.envfile is not pushed to GitHub for security reasons.