Skip to content

About

Task Manager Backend API built with Node.js, Express.js, MongoDB, and tested using Postman.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Task Manager Backend API

A backend REST API for managing tasks using Node.js, Express.js, MongoDB Atlas, and JWT authentication.

Live Deployment

Render Live Backend:

https://taskmanager-backend-98x0.onrender.com

Health Check API:

https://taskmanager-backend-98x0.onrender.com/api/health

GitHub Repository:

https://github.com/DOTJORDAN-Rahaf/TaskManager-Backend

Features

  • 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

Technologies

  • Node.js
  • Express.js
  • MongoDB Atlas
  • Mongoose
  • bcryptjs
  • jsonwebtoken
  • dotenv
  • cors
  • Postman
  • Render

Setup Locally

Install dependencies:

npm install

Create 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_key

Run the project in development mode:

npm run dev

Or run it using the start script:

npm start

Server runs locally on:

http://localhost:8000

Health check locally:

http://localhost:8000/api/health

Deployment on Render

The backend is deployed on Render as a Web Service.

Render settings:

Build Command:
npm install

Start Command:
npm start

Environment variables added on Render:

MONGO_URI
JWT_SECRET

Note: PORT is not added manually on Render because Render provides it automatically during deployment.

APIs

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

Authentication

Protected APIs require this header:

Authorization: Bearer TOKEN_HERE

Example Health Check Response

{
  "message": "Task Manager Backend is running"
}

Notes

  • 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 .env file is not pushed to GitHub for security reasons.

About

Task Manager Backend API built with Node.js, Express.js, MongoDB, and tested using Postman.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages