AspNet.KickStarter.CQRS.Abstractions
1.0.0
Prefix Reserved
See the version list below for details.
dotnet add package AspNet.KickStarter.CQRS.Abstractions --version 1.0.0
NuGet\Install-Package AspNet.KickStarter.CQRS.Abstractions -Version 1.0.0
<PackageReference Include="AspNet.KickStarter.CQRS.Abstractions" Version="1.0.0" />
paket add AspNet.KickStarter.CQRS.Abstractions --version 1.0.0
#r "nuget: AspNet.KickStarter.CQRS.Abstractions, 1.0.0"
// Install AspNet.KickStarter.CQRS.Abstractions as a Cake Addin #addin nuget:?package=AspNet.KickStarter.CQRS.Abstractions&version=1.0.0 // Install AspNet.KickStarter.CQRS.Abstractions as a Cake Tool #tool nuget:?package=AspNet.KickStarter.CQRS.Abstractions&version=1.0.0
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 that with Serilog and Swagger.
IEndpointRouteBuilder Extensions
These extensions simply consolidates 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;
new ApiBuilder()
.WithSerilog(msg => Console.WriteLine($"Serilog: {msg}")) // Optional Serilog diagnostic self logging action
.WithSwagger()
.WithServices(RegisterServices)
.WithEndpoints(MapEndpointsp)
.Build(args)
.Run();
void RegisterServices(WebApplicationBuilder builder)
=> builder.Services.AddTransient<HealthHandler>();
void MapEndpointsp(WebApplication app)
{
app.MapGet("/health/version", "GetVersion", "Get the API version",
async (HealthHandler handler) => await handler.GetVersionAsync());
}
This will use the Serilog configuration in appsettings.json
.
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 class GetVersionQuery : IQuery<string> { }
internal class GetVersionQueryHandler : IQueryHandler<GetVersionQuery, string>
{
public Task<string> Handle(GetVersionQuery query, CancellationToken cancellationToken) => Task.FromResult("1.0");
}
public class SetValueCommand : ICommand
{
public string Value { get; }
public SetValueCommand(string value) => Value = value;
}
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.