AspNet.KickStarter.CQRS.Abstractions
1.0.7
Prefix Reserved
Replaced with AspNet.KickStarter.CQRS that contains more functionality and a new Result type.
dotnet add package AspNet.KickStarter.CQRS.Abstractions --version 1.0.7
NuGet\Install-Package AspNet.KickStarter.CQRS.Abstractions -Version 1.0.7
<PackageReference Include="AspNet.KickStarter.CQRS.Abstractions" Version="1.0.7" />
paket add AspNet.KickStarter.CQRS.Abstractions --version 1.0.7
#r "nuget: AspNet.KickStarter.CQRS.Abstractions, 1.0.7"
// Install AspNet.KickStarter.CQRS.Abstractions as a Cake Addin #addin nuget:?package=AspNet.KickStarter.CQRS.Abstractions&version=1.0.7 // Install AspNet.KickStarter.CQRS.Abstractions as a Cake Tool #tool nuget:?package=AspNet.KickStarter.CQRS.Abstractions&version=1.0.7
AspNet.KickStarter
These libraries provide small helpers to reduce the repetitive code used to run my AspNet Minimal API projects.
AspNet.KickStarter
This library provides the following helpers
ApiBuilder
This simplifies the bootstrapping code to run a minimal API with optional support for Serilog, FluentValidation, Prometheus metrics and Swagger..
HealthHandler
Provides basic health checks - status and version.
IEndpointRouteBuilder Extensions
These extensions simply consolidate the AspNet extensions
app.MapXXX(route, handler)
.WithName(name)
.WithDescription(description)
.WithOpenApi()
into a single extension with parameters for the name and description.
MapXXX(route, name, description, handler)
Sample usage
Program.cs
using AspNet.KickStarter;
using AspNet.KickStarter.HttpHandlers;
using System.IO.Abstractions;
new ApiBuilder()
.WithSerilog(msg => Console.WriteLine($"Serilog: {msg}")) // Optional Serilog diagnostic self logging action
.WithSwagger()
.WithServices(RegisterServices)
.WithEndpoints(MapEndpointsp)
.WithFluentValidationFromAssemblyContaining<MyRequestValidator>()
.WithMetrics(8081)
.Build(args)
.Run();
void RegisterServices(WebApplicationBuilder builder)
=> builder.Services
.AddTransient<HealthHandler>()
.AddSingleton<IFileSystem, FileSystem>();
void MapEndpointsp(WebApplication app)
{
app.MapGet("/health/status", "GetHealthStatus", "Check API health",
(HealthHandler handler) => handler.GetStatus());
app.MapGet("/health/version", "GetVersion", "Get the API version",
async (HealthHandler handler) => await handler.GetVersionAsync());
}
This will use the Serilog configuration in appsettings.json
. For example:
appsettings.json
{
"Serilog": {
"Using": [ "Serilog.Sinks.Debug", "Serilog.Sinks.Console", "Serilog.Sinks.File", "Serilog.Sinks.Seq" ],
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"WriteTo": [
{
"Name": "Debug"
},
{
"Name": "Console"
},
{
"Name": "File",
"Args": {
"path": "My.Api_.log",
"rollingInterval": "Day",
"retainedFileCountLimit": 7
},
"MinimumLevel": "Information"
},
{
"Name": "Seq",
"Args": {
"serverUrl": "http://localhost:5341"
}
}
],
"Enrich": [ "FromLogContext" ],
"Properties": {
"Application": "My API"
}
}
}
AspNet.KickStarter.CQRS.Abstractions
This library provides the following basic interfaces used to implement CQRS with MediatR
- ICommand
- IQuery
Along with handler interfaces
- ICommandHandler
- IQueryHandler
Sample Usage
public record GetVersionQuery : IQuery<string> { }
internal class GetVersionQueryHandler : IQueryHandler<GetVersionQuery, string>
{
public Task<string> Handle(GetVersionQuery query, CancellationToken cancellationToken) => Task.FromResult("1.0");
}
public record SetValueCommand(string Value) : ICommand;
internal class SetValueCommandHandler : ICommandHandler<SetValueCommand>
{
public Task<Result> Handle(SetValueCommand command, CancellationToken cancellationToken)
{
try
{
// Set the value to command.Value
return Result.Success();
}
catch (Exception ex)
{
return Result.Failure(ex.Message);
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- CSharpFunctionalExtensions (>= 2.40.2)
- MediatR (>= 12.1.1)
-
net7.0
- CSharpFunctionalExtensions (>= 2.40.2)
- MediatR (>= 12.1.1)
-
net8.0
- CSharpFunctionalExtensions (>= 2.40.2)
- MediatR (>= 12.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.