This serves as the backend for the aarhusvandsportscenter.dk website.
Hosted at:
- http://aarhusvandsportscenter.dk/api/v1 (prod)
- http://århusvandsportscenter.dk/api/v1 (prod)
- http://dev.aarhusvandsportscenter.dk/api/v1 (dev)
Highlights:
- .Net 5
- The API is documented using Swagger UI at /swagger.
- The project administers an SQL Server database using Entity Framework and the code-first principle with migrations.
- .Net SDK 5.0.1
Read through the appsettings.json configuration file for any values missing. This is essential before the project can run without error. Using VS Code, a launch.json file can have a configuration containing an env object as such:
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"someprop:nestedprop": ""
}
Migrations are applied when the application starts and should generally not be applied manually using the command line. This means that upon deploying the app, migrations will automatically update the database. it is important to configure the connection string in appsettings.json temporarily. While you are working with a new database scheme you should not connect to the Test or Production database. It should point at a local database running on your machine so you dont accidentally mess up the database scheme on Test or Production. I use the following connection string to point at a locally running LocalDb, which can be installed as part of the SQL Server Express installation.
Install the EF global tool:
dotnet tool install --global dotnet-ef
To add new migrations
cd ./src/Aarhusvandsportscenter.Api/
dotnet ef migrations add InitialCreate -o ./Infastructure/Database/Migrations/
Using Dotnet
dotnet run --project ./src/Aarhusvandsportscenter.Api/
We're using Xunit and NSubstitute as mocking framework. We go with a most coverage with least effort mindset. The general strategy for testing is to success acceptance test all endpoints in the API with HTTP requests using WebApplicationFactory.
To run tests one can use a test explorer in the code editor or run the command: dotnet test
.
The same command is run as part of the deploy pipeline. Nothing will be deployed if any test fails.
The application is currently hosted at Simply.com. We use github actions as CI/CD tool. Upon pushing to the Dev branch, any changes will be deployed to our Test server. In the csproj file the following applies to the Debug configuration:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>
This enables running multiples applications in the IIS app-pool on the server. The main application runs In-process and all others run Out-of-process.