Skip to content

dev-chandan-s/task-manager-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Task Manager API

A RESTful Task Manager API built using Node.js, Express.js, MongoDB Atlas, and JWT Authentication.

Live Demo

🌐 Deployed API:

https://task-manager-api-u711.onrender.com

Test the API:

GET /

Response:

"Task Manager API running"

Features

βœ… User Registration (Signup)

βœ… User Login

βœ… Password Hashing using bcryptjs

βœ… JWT Authentication

βœ… Protected Routes

βœ… Create Tasks

βœ… View Personal Tasks

βœ… Update Tasks

βœ… Delete Tasks


Tech Stack

  • Node.js
  • Express.js
  • MongoDB Atlas
  • Mongoose
  • JWT (jsonwebtoken)
  • bcryptjs
  • dotenv
  • Render

What I Learned

  • Express.js Routing
  • Middleware
  • MongoDB & Mongoose
  • JWT Authentication
  • Password Hashing with bcryptjs
  • REST API Development
  • CRUD Operations
  • Environment Variables (.env)
  • Git & GitHub
  • Cloud Deployment using Render
  • Backend Project Structure using Controllers, Routes, Models, and Middleware

Project Structure

task-manager-api
β”‚
β”œβ”€β”€ config
β”‚   └── db.js
β”‚
β”œβ”€β”€ controllers
β”‚   β”œβ”€β”€ authController.js
β”‚   └── taskController.js
β”‚
β”œβ”€β”€ middleware
β”‚   └── verifyToken.js
β”‚
β”œβ”€β”€ models
β”‚   β”œβ”€β”€ User.js
β”‚   └── Task.js
β”‚
β”œβ”€β”€ routes
β”‚   β”œβ”€β”€ authRoutes.js
β”‚   └── taskRoutes.js
β”‚
β”œβ”€β”€ .env.example
β”œβ”€β”€ .gitignore
β”œβ”€β”€ README.md
β”œβ”€β”€ package.json
└── server.js

Installation

1. Clone the Repository

git clone https://github.com/dev-chandan-s/task-manager-api.git

2. Install Dependencies

npm install

3. Create a .env File

PORT=3000

MONGO_URI=YOUR_MONGODB_CONNECTION_STRING

JWT_SECRET=YOUR_SECRET_KEY

4. Start the Server

npm start

API Endpoints

Authentication

Register User

POST /api/auth/signup

Login User

POST /api/auth/login

Tasks

Get All Tasks

GET /api/tasks

Create Task

POST /api/tasks

Update Task

PATCH /api/tasks/:id

Delete Task

DELETE /api/tasks/:id

Testing the API

The API is deployed and publicly accessible:

https://task-manager-api-u711.onrender.com

You can test it using Postman, Thunder Client, Insomnia, or any REST client.

1. Register a User

Request:

POST https://task-manager-api-u711.onrender.com/api/auth/signup

Body:

{
  "email": "test@example.com",
  "password": "123456"
}

2. Login

Request:

POST https://task-manager-api-u711.onrender.com/api/auth/login

Body:

{
  "email": "test@example.com",
  "password": "123456"
}

Response:

{
  "token": "YOUR_JWT_TOKEN"
}

3. Create a Task

Request:

POST https://task-manager-api-u711.onrender.com/api/tasks

Headers:

authorization: YOUR_JWT_TOKEN

Body:

{
  "title": "Learn SQL"
}

4. Get All Tasks

Request:

GET https://task-manager-api-u711.onrender.com/api/tasks

Headers:

authorization: YOUR_JWT_TOKEN

5. Update a Task

Request:

PATCH https://task-manager-api-u711.onrender.com/api/tasks/:id

Headers:

authorization: YOUR_JWT_TOKEN

Replace :id with an actual task ID.


6. Delete a Task

Request:

DELETE https://task-manager-api-u711.onrender.com/api/tasks/:id

Headers:

authorization: YOUR_JWT_TOKEN

Replace :id with an actual task ID.


Security Features

  • Passwords are hashed using bcryptjs.
  • JWT Authentication protects task routes.
  • Users can only access their own tasks.
  • Sensitive credentials are stored in environment variables.

Future Improvements

  • Task Categories
  • Due Dates
  • Task Priorities
  • User Profile Management
  • Pagination
  • Input Validation using Express Validator
  • Refresh Tokens
  • Swagger API Documentation
  • Role-Based Authorization

Author

Chandan Singh

GitHub: https://github.com/dev-chandan-s

Project Repository: https://github.com/dev-chandan-s/task-manager-api

Live API: https://task-manager-api-u711.onrender.com

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors