AspNet.KickStarter.CQRS.Abstractions 1.0.0

Prefix Reserved
There is a newer version of this package available.
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                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AspNet.KickStarter.CQRS.Abstractions" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AspNet.KickStarter.CQRS.Abstractions --version 1.0.0                
#r "nuget: AspNet.KickStarter.CQRS.Abstractions, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.7 682 10/22/2023
1.0.6 151 10/21/2023
1.0.5 357 10/9/2023
1.0.4 103 10/6/2023
1.0.3 119 10/4/2023
1.0.2 106 10/3/2023
1.0.1 104 10/1/2023
1.0.0 109 9/30/2023