Initialization and configuration including useful base types for ASP.NET Core APIs.
$ dotnet add package devdeer.Libraries.AspNetCore.RestApi
If you want to use this package you should be aware of some principles and practices we at DEVDEER use. So be aware that this is not backed by a public repository. The purpose here is to give out customers easy access to our logic. Nevertheless you are welcome to use this lib if it provides any advantages.
This package is used to provide startup logic, base types and other specific logic to ASP.NET Core API projects.
Please keep in mind that this package is not intended to be used in UI web projects!
One of the main purposes for this packages was the fact, that the initial configuration of ASP.NET APIs can
be overwhelming. You need to inject dependencies and app components in the correct order. Also you often want
to put configuration of those things to outside stores (appsettings.json in our case). This package now
reduces all of this to only some lines of code. You could use this as follows in the Program.cs:
var builder = WebApplication
.CreateBuilder(args)
.ConfigureDefaults();
builder.Services.ConfigureServices(builder.Configuration, opt =>
{
// your explicit options and callbacks
});
// your additional DI here
var app = builder.Build();
app.ConfigureDefaults();
app.Run();
Now it is crucial to understand that ConfigureLogging(), ConfigureServices() and ConfigureDefaults()
are methods coming from this package. The outcome can be controlled in 2 ways:
ConfigurationOptions action. You can define some of the wanted behavior using the optional parameter provided by ConfigureServices() extension method.appsettings.*.json.Some common app settings are:
{
"EntraId": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "",
"Domain": ""
},
"Cors": {
"EnableCors": true,
"AllowCredentials": false,
"AllowedHeaders": ["*"],
"AllowedMethods": ["GET", "POST"]
},
"Swagger": {
"ApiDescription": "",
"DeprecatedApiMessage": "<p><strong><span style='color:white;background-color:red'>DEPRECATED</span></strong></p>",
"Contact": {
"Name": "",
"Email": ""
},
"SupportedVersions": [{
"Major": 1,
"Minor": 0
}],
"Enable": true
}
}
Using the syntax above will automatically configure the respective services in the correct order with just two lines of code.
If the EntraId config option is set we automatically configure authentication to EntraId or
Azure AD B2C/Entra ID Extenal Identities.
DEVDEER is a company from Magdeburg, Germany which is specialized in consulting, project management and development. We are very focussed on Microsoft Azure as a platform to run our products and solutions in the cloud. So all of our backend components usually runs in this environment and is developed using .NET. In the frontend area we are using react and a huge bunch of packages to build our UIs.
You can find us online: