Skip to content

Shreeja5714/ToDo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📝 Todo API

A RESTful API for managing todo items built with Node.js, Express, TypeScript, and MongoDB.

🚀 Features

  • ✅ Create, Read, Update, Delete (CRUD) operations
  • ✅ Auto-incrementing serial numbers
  • ✅ Status management (pending, in-progress, completed)
  • ✅ TypeScript for type safety
  • ✅ MongoDB with Mongoose ODM
  • ✅ Error handling with http-errors
  • ✅ Input validation

The server will start on http://localhost:3000

📁 Project Structure

todo-api/
├── config/
│   ├── config.ts
│   └── db.ts 
├── src/
│   ├── todo
│   │   ├── controller.ts         # Business logic
│   │   ├── routes.ts             # API routes
│   │   ├── model.ts              # MongoDB schema
│   │   └── types.ts              # TypeScript interfaces
│   └── app.ts
│   
├── .env                          # Environment variables
├── .gitignore
├── package.json
├── eslint.config.mjs
├── tsconfig.json
├── server.ts                 # Express app setup
└── README.md

🔌 API Endpoints

Base URL

http://localhost:3000/api

Endpoints

Method Endpoint Description
POST /todos Create a new todo
GET /todos Get all todos
GET /todos/:id Get a single todo by ID
PUT /todos/:id Update a todo
DELETE /todos/:id Delete a todo

🎨 Todo Schema

{
  sno: number,              // Auto-incrementing serial number
  title: string,            // Required
  description?: string,     // Optional
  status: 'pending' | 'in-progress' | 'completed',
  createdAt: Date,          // Auto-generated
  updatedAt: Date           // Auto-generated
}

🧪 Testing with Postman

  1. Set base URL: http://localhost:3000/api
  2. Test endpoints in this order:
    • Create a todo
    • Get all todos
    • Get single todo
    • Update todo
    • Delete todo

📦 Dependencies

{
  "express": "^4.18.2",
  "mongoose": "^8.0.0",
  "http-errors": "^2.0.0",
  "dotenv": "^16.3.1"
}

👤 Author

Shreeja Vyas

  • GitHub: shreeja5714

Happy Coding! 🚀

About

A RESTful API for managing todo items built with Node.js, Express, TypeScript, and MongoDB.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors