A Dotnet 8.0 WebApi template project. MediatR, Swagger, Mapper, Serilog and more implemented.
English | Português
A .Net 8.0
WebApi boilerplate / template project. MediatR, Swagger, AutoMapper Mapster, Serilog and more implemented.
The goal of this project is to be a kickstart to your .Net WebApi, implementing the most common used patterns and technologies for a restful API in .net, making your work easier.
docker-compose up -d db-server
. Doing that, the application will be able to reach the container of the db server.dotnet run
, or, in visual studio set the api project as startup and run as console/docker/IIS.docker-compose up -d
in the root directory, or, in visual studio, set the docker-compose project as startup and run. This should start the application and DB.dotnet dev-certs https -ep https/aspnetapp.pfx -p yourpassword
Replace "yourpassword" with something else in this command and the docker-compose.override.yml file.
This creates the https certificate.Important: You need to have docker up and running. The integration tests will launch a Postgres container and use it to test the API.
In the root folder, run dotnet test
. This command will try to find all test projects associated with the sln file.
If you are using Visual Studio, you can also access the Test Menu and open the Test Explorer, where you can see all tests and run all of them or one specifically.
In this project, some routes requires authentication/authorization. For that, you will have to use the api/identity/register
route to create an account.
After that, you can login using the /api/identity/login
without using cookies and then use received accessToken on the lock (if using swagger) or via the Authorization header on a http request.
For more information, please take a look on swagger documentation.
To run migrations on this project, you need the dotnet-ef tool.
dotnet tool install --global dotnet-ef
dotnet ef migrations add InitialCreate --startup-project .\src\Boilerplate.Api\ --project .\src\Boilerplate.Infrastructure\
dotnet ef migrations add InitialCreate --startup-project ./src/Boilerplate.Api/ --project ./src/Boilerplate.Infrastructure/
If this template was useful for you, or if you learned something, please give it a Star! :star:
This project has great influence of https://github.com/lkurzyniec/netcore-boilerplate and https://github.com/EduardoPires/EquinoxProject. If you have time, please visit these repos, and give them a star, too!
This boilerplate/template was developed by Yan Pitangui under MIT license.