Skip to content

πŸ“ A simple and secure To-Do List REST API built with Node.js, Express, and MongoDB. Features user authentication using JWT and CRUD operations for managing to-dos.

Notifications You must be signed in to change notification settings

ranadebsaha/Todo_API_Node-Js_Express-Js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ To-Do List API (Node.js + Express + MongoDB)

This is a simple and secure To-Do List API built with Node.js, Express.js, MongoDB, and JWT authentication. It allows users to register, log in, and perform full CRUD operations (Create, Read, Update, Delete) on their to-do tasks.


πŸš€ Features

  • πŸ” User registration and login with JWT authentication
  • πŸ›‘οΈ Protected routes using middleware
  • πŸ“ Create personal to-do tasks
  • πŸ“ƒ Retrieve all tasks of a user
  • 🧾 Update existing tasks
  • ❌ Delete tasks by ID

βš™οΈ Tech Stack

  • Node.js – JavaScript runtime
  • Express.js – Web framework
  • MongoDB – NoSQL database
  • Mongoose – ODM for MongoDB
  • JWT – JSON Web Token for authentication

πŸ“ Project Structure

. β”œβ”€β”€ db/ β”‚ β”œβ”€β”€ config.js # MongoDB connection β”‚ β”œβ”€β”€ User.js # User schema β”‚ └── Todo.js # Todo schema β”œβ”€β”€ index.js # Main API entry point


πŸ“¦ Setup Instructions

  1. Clone the repository:

    git clone https://github.com/your-username/todo-api.git
    cd todo-api
    
  2. Install dependencies:

    npm install
    
  3. Start MongoDB locally (or configure Atlas URI in db/config.js).

  4. Run the server:

    node index.js
  5. The server runs on http://localhost:5000

πŸ”‘ Authentication

All to-do routes are protected. Users must log in and pass the JWT token in the request header. ```bash auth: Bearer


πŸ“Œ API Endpoints

βœ… Authentication

Method Route Description
POST /register Register new user
POST /login Login and get token

πŸ“‹ To-Do Operations (Requires Token)

Method Route Description
POST /create Create new to-do
GET /todos/:author Get all to-dos for a user
PUT /update/:id Update to-do by ID
DELETE /delete/:id Delete to-do by ID

πŸ“„ Sample JSON Body

πŸ” Register / Login

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

πŸ“ Create a To-Do

{
  "name": "Buy groceries",
  "author": "user@example.com"
}

πŸ“œ License

This project is licensed for educational use. Contributions are welcome.

Made with πŸ’» by Ranadeb Saha

Let me know if you want this merged into your full README.md or need additional sections like DB schema or setup instructions.

About

πŸ“ A simple and secure To-Do List REST API built with Node.js, Express, and MongoDB. Features user authentication using JWT and CRUD operations for managing to-dos.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published