Skip to content

TechbroMoh/ToDoList-RESTFUL-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ToDoList API

Introduction

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.

Project Scope and Objectives

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

Tech Stack

  • Node.js – JavaScript runtime
  • Express.js – Fast web framework for Node.js
  • MongoDB Atlas – Cloud database
  • Mongoose – ODM library for MongoDB

Prerequisites

Before running this project, ensure you have:

  • Node.js installed
  • MongoDB Atlas account (or MongoDB installed locally)
  • Postman (optional, for testing API requests)

Getting Started

1. Clone the Repository

git clone [email protected]:TechbroMoh/ToDoList-RESTFUL-API.git
cd To-Do-List-REST-API

2. Install Dependencies

npm install

3. Set Up MongoDB Atlas Connection

  1. Go to MongoDB Atlas
  2. Create a new cluster
  3. Get your MongoDB connection string
  4. Create a .env file in the root of your project:
touch .env
  1. 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.

4. Start MongoDB Shell (Local Users Only)

If using local MongoDB, run:

mongosh

If using MongoDB Atlas, skip this step.

5. Run the Server

node server.js

You'll see:

Todo List RESTful API server started on port: 4000
MongoDB connected successfully to Atlas

API Endpoints

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

Example Request - Create a Task

POST /tasks

{
  "name": "Write Blog Post",
  "description": "Complete the article on MongoDB",
  "status": ["pending"]
}

Testing the API with Postman

  1. Open Postman
  2. Select POST
  3. Enter http://localhost:4000/tasks
  4. Go to Body → raw → JSON and add:
{
  "name": "Techbro@Civic",
  "description": "Civic Voices is the Public Participation platform",
  "status": ["ongoing"]
}
  1. Click Send

License

This project is licensed under the MIT License.

Acknowledgements

  • Express.js – Web framework
  • Mongoose – MongoDB ODM
  • MongoDB Atlas – NoSQL cloud database
  • Node.js – JavaScript runtime

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published