Skip to content

calKU0/ToDoAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ToDo API Project

🧪 Personal Project — built for experimentation, fun, or learning.

This is a simple REST API built using .NET 8.0, that handles typical CRUD operations for a ToDo application. The API allows users to create, retrieve, update, delete, and manage ToDo items, with additional functionality like tracking progress and marking items as done.

Table of Contents

Description

This ToDo API allows users to manage their ToDo tasks. Each task has the following properties:

  • Date and Time of expiry
  • Title
  • Description
  • % Complete

Features

  • Create, update, delete, and retrieve ToDo tasks.
  • Mark tasks as "Done" and track their progress through a percentage completion.
  • Filter tasks for today, next day, and current week.

Technologies

  • .NET 8.0
  • Entity Framework Core (EF Core)
  • PostgreSQL (for database management)
  • xUnit (for unit and integration testing)
  • Docker (for containerization)

Setup

Prerequisites

Before running this project, make sure you have the following installed:

  • .NET 8.0 SDK
  • Docker (optional, for containerized environment)
  • A PostgreSQL database (configured through Docker Compose in the provided docker-compose.yml file)

1. Clone the Repository

Clone the repository to your local machine:

git clone https://github.com/calKU0/ToDoAPI.git
cd to-do-api

2. Configure the Database

The application uses Docker Compose to set up a PostgreSQL database.

Ensure that your appsettings.json file has the following connection string to connect to the Dockerized PostgreSQL database:

{
  "ConnectionStrings": {
    "DefaultConnection": "Host=db;Database=todo;Username=postgres;Password=password"
  }
}

3. Docker Setup

This project uses Docker Compose to handle both the API and database.

  • Navigate to the project root directory where the docker-compose.yml file is located.
  • Run the following command to start the services (PostgreSQL and the API):
docker-compose up --build

This will set up both the database and API container.

4. Access the API

Once the containers are up and running, the API will be available at:

http://localhost:8080

Endpoints

The following endpoints are available in the API:

  • GET /api/todo: Retrieve all ToDos.
  • GET /api/todo/{id}: Retrieve a specific ToDo by ID.
  • POST /api/todo: Create a new ToDo.
  • PUT /api/todo/{id}: Update an existing ToDo by ID.
  • DELETE /api/todo/{id}: Delete a ToDo by ID.
  • GET /api/todo/incoming: Get ToDos for today/next day/current week.

Running in Docker

1. Build the Docker Image

Ensure Docker is installed and running. Build the Docker image for the API:

docker build -t todo-api .

2. Start the Services Using Docker Compose

Make sure your docker-compose.yml file is set up correctly in the root directory, then run:

docker-compose up --build

This command will start the PostgreSQL database and the API services.

3. Access the API

Once everything is up and running, the API will be available at http://localhost:8080.

Testing

1. Run Unit Tests

The project uses xUnit for unit testing. You can run the tests by executing:

dotnet test

2. Run Integration Tests

Make sure your Dockerized PostgreSQL database is running. The integration tests will verify that the API works with the database.

About

A simple REST API to handle ToDo operations build using .NET 8.0

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published