A basic API for a blogging platform, built with .NET 6 minimal API
One of the main benefits I see in the .NET 6 minimal API is that it less opinionated on how you should organize your code then the regular controller-based approach. That's why we have implemented a minimal API using the following principles:
- Vertical slices architecture (feature-based organization)
- CQRS using MediatR
- Auto-registered modules for each feature
- AutoMapper
- Record types for DTOs
- (Kind of) rich domain model
- No repository and services layer. Everything is handled by the
IRequestHandlers
- Splitting read and write endpoints into different files
Running the API is very easy:
- Provide a connection string in the
appsettings.json
file - Run
update-database
in the Package Manager Console or with the .NET Core CLI (make sure you target the Thoightful.Dal project, as all migrations are there) - Run the API and play with it
- You'll need the .NET 6 RC2 SDK to run the app. My suggestion is to run it in Visual Studio 2022.
This project was built during 4 different live coding sessions on Youtube. YouTube channel: Codewrinkles