NeatApi 0.0.1-alpha.3

This is a prerelease version of NeatApi.
dotnet add package NeatApi --version 0.0.1-alpha.3                
NuGet\Install-Package NeatApi -Version 0.0.1-alpha.3                
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="NeatApi" Version="0.0.1-alpha.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NeatApi --version 0.0.1-alpha.3                
#r "nuget: NeatApi, 0.0.1-alpha.3"                
#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 NeatApi as a Cake Addin
#addin nuget:?package=NeatApi&version=0.0.1-alpha.3&prerelease

// Install NeatApi as a Cake Tool
#tool nuget:?package=NeatApi&version=0.0.1-alpha.3&prerelease                

NEAT API

NuGet Version GitHub last commit

A super simple library to help you modularize your minimal API projects.

Install

dotnet add package NeatApi

Usage

Add NeatApi to your app

Looking for detail implementations in the folder /samples. Here is the basic usage:

var builder = WebApplication.CreateBuilder(args);

+ builder.AddNeatApi();

var app = builder.Build();

+ app.MapNeatApi();

app.Run();

Register Services

public class WeatherForecastServices : IServiceModule
{
    public void Register(IServiceCollection services, IServiceModuleContext context)
    {
        services.AddSingleton<IWeatherForecastRepo, SampleWeatherForecastRepo>();

        services.AddOptionsWithValidateOnStart<WeatherForecastOptions>()
            .BindConfiguration(WeatherForecastOptions.Name);
    }
}

Define Routes

General Cases
public class WeatherForecastRoutes : IRoutingModule
{
    protected void AddRoutes(IEndpointRouteBuilder app, IRoutingModuleContext context)
    {
        app.MapGet("/weatherforecast", (IWeatherForecastRepo repo) =>
        {
            return repo.GetForecasts();
        })
        .WithName("GetWeatherForecast")
        .WithOpenApi();

        if (context.Environment.IsDevelopment())
        {
            app.MapGet("debug", () =>
            {
                return "dotnet v" + Environment.Version.ToString();
            });
        }
    }
}
Grouped Routes
public class WeatherForecastRoutes() : GroupedRoutingModuleBase("/weatherforecast")
{
    protected override void AddRoutes(IEndpointRouteBuilder app, IEndpointConventionBuilder convention, IRoutingModuleContext context)
    {
        convention.WithTags("WeatherForecast").WithOpenApi();

        app.MapGet("", (IWeatherForecastRepo repo) =>
        {
            return repo.GetForecasts();
        }).WithName("GetWeatherForecast");
    }
}

License

MIT

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.
  • net8.0

    • No dependencies.

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
0.0.1-alpha.3 39 8/4/2024