Skip to content

alahyarlou/Task-Api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📝 Todo API

A simple RESTful API for managing tasks (Todos) built with Node.js, Express.js, and MongoDB.
This project demonstrates fundamental backend concepts such as CRUD operations, validation, and API architecture.


🚀 Features

  • Create, Read, Update, and Delete tasks (CRUD)
  • Input validation with Joi
  • Modular architecture (Models, Controllers, Routes, Middlewares)
  • MongoDB integration with Mongoose
  • Standardized error handling and responses
  • Dockerized (Node.js + MongoDB with Docker Compose)

📂 Project Structure

│── src/
│ ├── controllers/
│ ├── models/
│ ├── routes/
│ ├── validations/
│ ├── middlewares/
│ └── app.js
│── .gitignore
│── Dockerfile
│── docker-compose.yml
│── .dockerignore
│── package.json
│── README.md

⚙️ Installation & Setup

1. Clone the repository

git clone https://github.com/alahyarlou/todo-api.git
cd todo-api

2. Install dependencies

npm install

3. Environment variables

Create a .env file in the project root:

MONGO_URI=mongodb://localhost:27017/todo-api
PORT=5000

4. Run the server (you need MongoDB installed locally)

npm run dev

▶️ Option 2: Run with Docker 🐳 (recommended)

1. Make sure you have Docker & Docker Compose installed

2. Configure environment variables

Update .env file like this:

MONGO_URI=mongodb://mongo:27017/todo-api
PORT=5000

3. Build and start containers

docker-compose up --build

4. Access the API

The server will be running at:

http://localhost:5000/api/tasks

MongoDB will be running inside its own container (mongo) and data will be persisted with Docker volumes.

🌐 API Endpoints

📌 Tasks

  • GET /api/tasks → Get all tasks

  • POST /api/tasks → Create a new task

  • GET /api/tasks/:id → Get a task by ID

  • PUT /api/tasks/:id → Update a task

  • DELETE /api/tasks/:id → Delete a task

🧪 Testing

You can test the API using Postman or Insomnia.

Example request to create a task:

POST http://localhost:5000/api/tasks
Content-Type: application/json

{
  "title": "Build Todo API",
  "description": "CRUD with Express and MongoDB"
}

📌 Future Improvements

  • Add User Authentication (JWT)

  • Unit and integration tests (Jest + Supertest)

  • CI/CD pipeline setup


👨‍💻 Author

About

A simple RESTful API for managing tasks (Todo App) built with Node.js, Express, and MongoDB.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors