This project is a .NET 9 API for a task management system with a specific set of requirements. The system allows users to create, update, delete, and retrieve tasks. It includes custom middleware that logs every API request, including method type and endpoint, into a file. When a task with "High" priority is created or updated, an event is triggered that logs it separately as a critical update. The project is secured using JWT authentication, designed in a very basic way for demonstration purposes only, and not production-ready.
Unit and integration tests are implemented using xUnit and Moq. The system uses SQLite for data persistence, creating/initialising a file when the API starts and deleting it upon application shutdown. Additionally, the project utilizes AutoMapper, MediatR, Dapper, and OpenAPI/Swagger to enhance functionality.
Before setting up the project, ensure you have the following installed:
- .NET 9 SDK: You can download and install it from the official .NET website.
If you want to follow Option 1, you'll need the following installed:
- Git: You need Git installed to clone the repository. You can download it from here.
If you prefer to clone the repository, follow these steps:
-
Clone the repository Open a terminal or command prompt and run the following command:
git clone https://github.com/tgrifoni/task-management-api.git
-
Navigate to the project directory Once the repository is cloned, navigate to the project directory:
cd task-management-api
If you prefer to download the files directly, follow these steps:
-
Download the files Download the project files from the repository in a ZIP format and extract them to a directory on your local machine.
-
Navigate to the project directory Open a terminal or command prompt and navigate to the extracted project directory:
cd path-to-extracted-directory/task-management-apiReplace
path-to-extracted-directorywith the actual path where you extracted the files.
If you don't have the .NET 9 SDK installed, download and install it from the official .NET website. Follow the installation instructions provided on the website.
Now, build the project to restore dependencies and compile the code. Run the following command in the terminal:
dotnet buildTo run the project using the CLI, execute the following command in the project directory:
dotnet run --project .\TaskManagement.Api\TaskManagement.Api.csprojThe API will start, and you should see output indicating that it's running on a specific URL, typically http://localhost:5000 or similar.
If you prefer using an IDE such as Visual Studio or Visual Studio Code, follow these steps:
- Open the project: Open your preferred IDE and load the project by selecting the
TaskManagement.slnsolution. - Build the solution: Use the build option in your IDE to compile the project.
- Run the project: Use the run/debug option in your IDE to start the project. The API will start running on a local server, typically accessible at
http://localhost:5000or a similar URL.
- You can also navigate to the Swagger page by adding
/swaggerto the end of the URL. - To log in, you can use the
adminusername andpasswordpassword to generate an access token. Any other combination will result in an401 Unauthorizedresponse. - The access token is set to expire in 120 seconds (2 minutes). You can change it by editing the amount of seconds in the
appsettings.jsonfile, underJwt__SecondsToExpire.
If you encounter any issues during setup or running the project, check the following:
- Ensure that you have the correct version of the .NET SDK installed.
- Verify that all dependencies are properly restored by running
dotnet restore. - Check the terminal or IDE output for any error messages and follow the suggestions provided.
For further assistance, feel free to open an issue in the GitHub repository or contact me.
Thank you for taking the time to set up and run this project. I hope this README has been helpful. Happy coding !