Base Web API Project Template¶
You can find the official source for the template here: GitHub – Base Web API Template
Overview¶
A minimal .NET Web API host with JWT auth, Swagger, Serilog, and the Domain Services infrastructure wired up. It has no domain-specific code — you add packages and register services inside a designated #region in Program.cs.
Adding Services¶
The intended place for adding your own Web APIs, providers, and repository configurations is here:
#region Install Web APIs and providers and configure more services here.
// https://developerdoc-mike-platform-prod.eu.mike-cloud.com/domain_services/how-to/#configuration-in-code
#endregion
For instructions and examples on injecting connections and repositories, see: Connections Project Template
Configuration¶
The main configuration file is appsettings.json.
Key sections include:
AppConfiguration– General server settings (e.g., HSTS).Tokens– JWT issuer, audience, and RSA public key.Swagger– API documentation title, description, and specification name.
Example appsettings.json:
{
"AppConfiguration": {
"HstsMaxAgeInDays": 1
},
"Tokens": {
"Issuer": "dhigroup.com",
"Audience": "dhigroup.com",
"PublicRSAKey": "[env:PublicRSAKey]"
},
"Swagger": {
"SpecificationName": "MyApplicationOpenAPISpecification",
"DocumentName": "MyApplicationWebAPI",
"DocumentTitle": "My Application Web API",
"DocumentDescription": "[AppData]SwaggerInfo.md"
}
}
Tip: Use
[env:...]placeholders for sensitive keys likePublicRSAKey.
Running the Base Web API¶
Requirements¶
- .NET SDK — check the template on GitHub for the current target framework
- Any required provider/domain NuGet packages
Steps¶
- Clone the template.
-
Install the Domain Services packages you need, for example:
dotnet add package DHI.Services.TimeSeries.WebApi dotnet add package DHI.Services.PostgreSQL -
Add service registration in the designated
#region. - Update
appsettings.jsonwith your JWT keys, CORS, and Swagger info. -
Run:
dotnet run -
Access Swagger UI at:
http://localhost:5000/swagger
Security Notes¶
- Store RSA keys securely, don’t commit production keys in source control.
- Keep
ClockSkew = TimeSpan.Zeroif you want strict token validation. - Use HTTPS in production (already enforced via HSTS).
Related Documentation¶
- Connections Project Template — how to register services.
- Domain Services Overview
- How to Leverage Domain Services