The ToDoList API is a RESTful web service that allows users to manage their tasks efficiently. It enables CRUD (Create, Read, Update, Delete) operations on tasks stored in a MongoDB database.
This API allows users to:
- ✅ Add new tasks to a list
- ✅ Update task details (e.g., status, description)
- ✅ Delete tasks
- ✅ View all tasks or a specific task
- Node.js – JavaScript runtime
- Express.js – Fast web framework for Node.js
- MongoDB Atlas – Cloud database
- Mongoose – ODM library for MongoDB
Before running this project, ensure you have:
- Node.js installed
- MongoDB Atlas account (or MongoDB installed locally)
- Postman (optional, for testing API requests)
git clone [email protected]:TechbroMoh/ToDoList-RESTFUL-API.git
cd To-Do-List-REST-API
npm install
- Go to MongoDB Atlas
- Create a new cluster
- Get your MongoDB connection string
- Create a
.env
file in the root of your project:
touch .env
- Add this inside
.env
:
MONGO_URI=mongodb+srv://your-username:[email protected]/ToDo
PORT=4000
In this case, I used the following MongoDB URI to connect to my database:
MONGO_URI=mongodb+srv://felixmonari:[email protected]/ToDo
Additionally, I was running the server locally on port 4000. You can change the PORT value if you want to use a different one.
Make sure to replace felixmonari and monari24 with your own MongoDB credentials.
If using local MongoDB, run:
mongosh
If using MongoDB Atlas, skip this step.
node server.js
You'll see:
Todo List RESTful API server started on port: 4000
MongoDB connected successfully to Atlas
Method | Endpoint | Description |
---|---|---|
GET | /tasks |
Get all tasks |
GET | /tasks/:taskId |
Get a specific task by ID |
POST | /tasks |
Create a new task |
PUT | /tasks/:taskId |
Update a task by ID |
DELETE | /tasks/:taskId |
Delete a task |
POST /tasks
{
"name": "Write Blog Post",
"description": "Complete the article on MongoDB",
"status": ["pending"]
}
- Open Postman
- Select POST
- Enter
http://localhost:4000/tasks
- Go to Body → raw → JSON and add:
{
"name": "Techbro@Civic",
"description": "Civic Voices is the Public Participation platform",
"status": ["ongoing"]
}
- Click Send ✅
This project is licensed under the MIT License.
- Express.js – Web framework
- Mongoose – MongoDB ODM
- MongoDB Atlas – NoSQL cloud database
- Node.js – JavaScript runtime