Suwbackkit.Server
0.2.1
See the version list below for details.
dotnet add package Suwbackkit.Server --version 0.2.1
NuGet\Install-Package Suwbackkit.Server -Version 0.2.1
<PackageReference Include="Suwbackkit.Server" Version="0.2.1" />
<PackageVersion Include="Suwbackkit.Server" Version="0.2.1" />
<PackageReference Include="Suwbackkit.Server" />
paket add Suwbackkit.Server --version 0.2.1
#r "nuget: Suwbackkit.Server, 0.2.1"
#:package Suwbackkit.Server@0.2.1
#addin nuget:?package=Suwbackkit.Server&version=0.2.1
#tool nuget:?package=Suwbackkit.Server&version=0.2.1
Suwbackkit.Server
Server defaults for the ASP.NET Core backends of Manomenu's apps, in two calls, the way .NET Aspire's ServiceDefaults does it:
- Logging: JSON on the console, with scopes and UTC timestamps;
Microsoft.AspNetCoreatWarning. These are the lowest-priority configuration values, soappsettings.jsonor environment variables override any of them (Logging__Console__FormatterName=simple). - ProblemDetails: every error is
application/problem+jsonwith atraceId(the W3C trace id the logs carry in their scope), from unhandled exceptions (UseExceptionHandler) and from empty error responses such as 404 (UseStatusCodePages). - OpenAPI:
AddOpenApiwith the document pinned to OpenAPI 3.1, so a newer .NET does not change the contract on its own. The pin holds for the document served at run time and for the oneMicrosoft.Extensions.ApiDescription.Serverwrites at build time: the build ignoresOpenApiOptions, so the package also adds--openapi-version OpenApi3_1toOpenApiGenerateDocumentsOptions, unless the app's project already names a version there. An app adds its own options with anotherAddOpenApi(...)call. - Health checks:
/healthruns every check (503 when one fails),/aliveonly the liveness ones (the process answers); both stay out of the OpenAPI document and answer without credentials (AllowAnonymous), also in an app whose other endpoints ask for them. Other packages add their checks withAddHealthChecks(), asSuwbackkit.Postgresdoes. - Contract schemas (opt-in):
AddOpenApi(options => options.AddContractSchemas())makes every schema say what the JSON always holds, so the types an app generates from the document (openapi-typescript) need no?or| nullwhere the server never leaves a value out: a property the server always writes and never asnull(a get-only property of a non-null reference type, which ASP.NET Core leaves optional and nullable) is required and not nullable; a union's discriminator ([JsonPolymorphic]) is required in each of its variants; andnullis no value of an enum (ASP.NET Core adds it to an enum used only as a nullable property, whose property already saysnull). /api/healthin the contract:MapHealthStatus()on a route group mapsGET <group>/health, answering{"status":"ok"}, or 503 ProblemDetails naming the failed checks; it answers without credentials too.
Usage
using Suwbackkit.Server;
var builder = WebApplication.CreateBuilder(args);
builder.AddServerDefaults();
var app = builder.Build();
app.MapServerDefaults();
app.MapGroup("/api").MapHealthStatus();
app.Run();
With the contract schemas, and the app's own OpenAPI options beside them:
builder.Services.AddOpenApi(options => options.AddContractSchemas());
Call MapServerDefaults() right after Build(): it puts the exception handler first in the pipeline.
ServerDefaults.WritingOpenApiDocument is true while the build-time OpenAPI generator (GetDocument.Insider) runs the app only to read its
routes: skip anything that needs the outside world then, such as migrations or background workers.
builder.Services.AddDatabase(builder.Configuration, migrateOnStart: !ServerDefaults.WritingOpenApiDocument);
ServerKit.Version is the version of this package, for an app that logs which kit it runs.
Source, license and changes: https://github.com/Manomenu/suwbackkit
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.OpenApi (>= 10.0.12)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.