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.
- 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)
│── src/
│ ├── controllers/
│ ├── models/
│ ├── routes/
│ ├── validations/
│ ├── middlewares/
│ └── app.js
│── .gitignore
│── Dockerfile
│── docker-compose.yml
│── .dockerignore
│── package.json
│── README.md
git clone https://github.com/alahyarlou/todo-api.git
cd todo-apinpm installCreate a .env file in the project root:
MONGO_URI=mongodb://localhost:27017/todo-api
PORT=5000npm run devUpdate .env file like this:
MONGO_URI=mongodb://mongo:27017/todo-api
PORT=5000docker-compose up --buildThe server will be running at:
http://localhost:5000/api/tasksMongoDB will be running inside its own container (mongo) and data will be persisted with Docker volumes.
-
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
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"
}
-
Add User Authentication (JWT)
-
Unit and integration tests (Jest + Supertest)
-
CI/CD pipeline setup
- Ali Alahyarlou - GitHub