AbsoluteAlgorithm.Api.Common 1.0.0-dev.12

This is a prerelease version of AbsoluteAlgorithm.Api.Common.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package AbsoluteAlgorithm.Api.Common --version 1.0.0-dev.12
                    
NuGet\Install-Package AbsoluteAlgorithm.Api.Common -Version 1.0.0-dev.12
                    
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="AbsoluteAlgorithm.Api.Common" Version="1.0.0-dev.12" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AbsoluteAlgorithm.Api.Common" Version="1.0.0-dev.12" />
                    
Directory.Packages.props
<PackageReference Include="AbsoluteAlgorithm.Api.Common" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AbsoluteAlgorithm.Api.Common --version 1.0.0-dev.12
                    
#r "nuget: AbsoluteAlgorithm.Api.Common, 1.0.0-dev.12"
                    
#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.
#:package AbsoluteAlgorithm.Api.Common@1.0.0-dev.12
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AbsoluteAlgorithm.Api.Common&version=1.0.0-dev.12&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=AbsoluteAlgorithm.Api.Common&version=1.0.0-dev.12&prerelease
                    
Install as a Cake Tool

AbsoluteAlgorithm.Api.Common

A comprehensive common library for building robust ASP.NET Core Web APIs, featuring database management, audit logging, rate limiting, and standard middleware pipelines.

Installation

Install the package via NuGet:

dotnet add package AbsoluteAlgorithm.Api.Common --prerelease

Usage Setup

Configure the application in Program.cs using ApplicationConfiguration to set up databases, rate limiting, and the absolute pipeline.

try
{
    ApplicationConfiguration appConfig = new ApplicationConfiguration
    {
        UseRelationalDatabase = true,
        DatabasePolicies = new List<DatabasePolicy>
        {
            new DatabasePolicy
            {
                DatabaseProvider = DatabaseProvider.MSSQL,
                ConnectionStringName = "MSSQLCS",
                InitializeDatabase = true,
                InitializeAuditTable = true,
                InitializationScript = msSqlScript,
                DatabaseName = "testdb",
                MaxPoolSize = 100,
                MinPoolSize = 10,
                CommandTimeoutSeconds = 30
            },
            new DatabasePolicy
            {
                DatabaseProvider = DatabaseProvider.PostgreSQL,
                ConnectionStringName = "POSTGRESCS",
                InitializeDatabase = true,
                InitializeAuditTable = true,
                InitializationScript = postgreSqlScript,
                DatabaseName = "test_db",
                MaxPoolSize = 100,
                MinPoolSize = 10,
                CommandTimeoutSeconds = 30
            }
        },
        UseRateLimit = true,
        RateLimitPolicies = new List<RateLimitPolicy>
        {
            new RateLimitPolicy
            {
                PolicyName = "rpol",
                Algorithm = RateLimitAlgorithm.FixedWindow,
                Scope = RateLimitScope.IpAddress,
                PermitLimit = 2,
                Window = TimeSpan.FromSeconds(2)
            }
        }
    };
    #endregion

    WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
    builder.RegisterAbsoluteWebApplicationBuilder(appConfig);

    WebApplication app = builder.Build();

    app.UseAbsolutePipeline(appConfig);

    app.Run();
}
catch (Exception ex)
{
    var logger = LogManager.GetCurrentClassLogger();
    logger.Error(ex, "an error occured: {message}", ex.Message);
    throw;
}
finally
{
    LogManager.Shutdown();
}

Configuration Reference

ApplicationConfiguration

Property Type Description
UseRelationalDatabase bool Enables relational database services and middleware.
DatabasePolicies List<DatabasePolicy> List of database configurations to initialize and manage.
UseRateLimit bool Enables rate limiting middleware.
RateLimitPolicies List<RateLimitPolicy> List of rate limiting policies to apply.

DatabasePolicy

Property Type Description
DatabaseProvider DatabaseProvider The database type (e.g., MSSQL, PostgreSQL).
ConnectionStringName string Environment variable name containing the connection string.
InitializeDatabase bool If true, attempts to create the database if it doesn't exist.
InitializeAuditTable bool If true, sets up the audit_logs table and triggers.
InitializationScript string Custom SQL script executed during initialization (e.g., table creation).
DatabaseName string Unique name for the database connection (used for pooling/resources).
MaxPoolSize int Maximum size of the connection pool.
MinPoolSize int Minimum size of the connection pool.
CommandTimeoutSeconds int Time in seconds before a command times out.

RateLimitPolicy

Property Type Description
PolicyName string Unique identifier for the policy (used in [EnableRateLimiting]).
Algorithm RateLimitAlgorithm The rate limiting algorithm (e.g., FixedWindow).
Scope RateLimitScope Scope of the limit (e.g., IpAddress, User).
PermitLimit int Number of permitted requests in the window.
Window TimeSpan Time window duration for the limit.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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