AspNet.KickStarter 1.0.7

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package AspNet.KickStarter --version 1.0.7                
NuGet\Install-Package AspNet.KickStarter -Version 1.0.7                
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" Version="1.0.7" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AspNet.KickStarter --version 1.0.7                
#r "nuget: AspNet.KickStarter, 1.0.7"                
#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 as a Cake Addin
#addin nuget:?package=AspNet.KickStarter&version=1.0.7

// Install AspNet.KickStarter as a Cake Tool
#tool nuget:?package=AspNet.KickStarter&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 Compatible and additional computed target framework versions.
.NET 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.2.3 109 6/18/2024
1.2.2 237 6/3/2024
1.2.1 68 6/3/2024
1.2.0 66 6/3/2024
1.1.0 332 12/4/2023
1.0.7 593 10/22/2023
1.0.6 152 10/21/2023
1.0.5 379 10/9/2023
1.0.4 119 10/6/2023
1.0.3 142 10/4/2023
1.0.2 120 10/3/2023
1.0.1 114 10/1/2023
1.0.0 120 9/30/2023