AstreCode.Backend.Shared.API 10.0.1.4

dotnet add package AstreCode.Backend.Shared.API --version 10.0.1.4
                    
NuGet\Install-Package AstreCode.Backend.Shared.API -Version 10.0.1.4
                    
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="AstreCode.Backend.Shared.API" Version="10.0.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AstreCode.Backend.Shared.API" Version="10.0.1.4" />
                    
Directory.Packages.props
<PackageReference Include="AstreCode.Backend.Shared.API" />
                    
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 AstreCode.Backend.Shared.API --version 10.0.1.4
                    
#r "nuget: AstreCode.Backend.Shared.API, 10.0.1.4"
                    
#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 AstreCode.Backend.Shared.API@10.0.1.4
                    
#: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=AstreCode.Backend.Shared.API&version=10.0.1.4
                    
Install as a Cake Addin
#tool nuget:?package=AstreCode.Backend.Shared.API&version=10.0.1.4
                    
Install as a Cake Tool

AstreCode.Backend.Shared.API

Shared backend components for AstreCode microservices.

Description

The AstreCode.Backend.Shared.API package provides essential shared components for building robust and scalable .NET 8.0 backend services. This package includes common middleware, configuration extensions, and utilities that streamline the development of microservices and API applications.

Installation

To install this package, use the .NET CLI:

dotnet add package AstreCode.Backend.Shared.API

Or via Package Manager Console:

Install-Package AstreCode.Backend.Shared.API

Features

🔧 Shared DTOs

  • Standardized response models and data transfer objects
  • Consistent API response formatting across all services
  • Generic response wrapper for uniform API responses

🛡️ Common Middleware

  • Global Exception Handler: Centralized error handling and logging
  • Application Middleware: Request/response processing and correlation tracking
  • Tenant Middleware: Multi-tenant support for SaaS applications
  • Token Expiration Check: Automatic JWT token validation and refresh
  • API Response Format Filter: Standardized response formatting
  • Permission Authorization: Role and permission-based access control
  • Group Authorization: Group-based access control

⚙️ Configuration Extensions

  • API Configuration: Centralized API settings and versioning
  • Serilog Configuration: Structured logging setup and configuration
  • SSL/TLS Options: Secure communication configuration
  • Security Extensions: Authentication and authorization setup

🔐 Security Features

  • JWT Bearer token authentication
  • Permission-based authorization attributes
  • Group-based authorization
  • SSL/TLS configuration options
  • Secure token validation and expiration handling

📊 Monitoring & Logging

  • Serilog integration for structured logging
  • Prometheus metrics support
  • Health check endpoints
  • Request/response correlation tracking

Example Usage

Basic Setup

using Shared.API;

var builder = WebApplication.CreateBuilder(args);

// Add API services
builder.Services.AddApiServices(builder.Configuration);

// Add security
builder.Services.AddSecurity(builder.Configuration);

var app = builder.Build();

// Configure API pipeline
app.UseApiPipeline();

app.Run();

Global Exception Handling

// The global exception handler is automatically configured
// when you use the API pipeline setup
app.UseApiPipeline();

Permission-Based Authorization

[ApiController]
[Route("api/[controller]")]
public class ExampleController : ControllerBase
{
    [HttpGet]
    [PermissionAuthorize("Read:Example")]
    public async Task<IActionResult> GetExample()
    {
        // Your implementation here
        return Ok();
    }
}

Group-Based Authorization

[ApiController]
[Route("api/[controller]")]
public class AdminController : ControllerBase
{
    [HttpGet]
    [GroupAuthorize("Administrators")]
    public async Task<IActionResult> GetAdminData()
    {
        // Your implementation here
        return Ok();
    }
}

SSL/TLS Configuration

// In appsettings.json
{
  "SSLOptions": {
    "IsEnabled": true,
    "CertificatePath": "path/to/certificate.pfx",
    "CertificatePassword": "your-password",
    "Port": 443
  }
}

Configuration

API Configuration

// In appsettings.json
{
  "ApiConfiguration": {
    "CorsOrigin": "https://yourdomain.com",
    "CorsHeaders": "*",
    "CorsMethods": "*",
    "MajorVersion": 1,
    "MinorVersion": 0
  }
}

Serilog Configuration

// In appsettings.json
{
  "Serilog": {
    "SeqUrl": "http://localhost:5341",
    "LogPath": "logs/app.log"
  }
}

Dependencies

This package depends on the following NuGet packages:

  • Microsoft.AspNetCore.Authentication.JwtBearer (8.0.7)
  • Microsoft.EntityFrameworkCore.Design (8.0.7)
  • Serilog.AspNetCore (8.0.2)
  • Swashbuckle.AspNetCore (6.7.0)
  • prometheus-net.AspNetCore (8.2.1)

Requirements

  • .NET 8.0 or later
  • ASP.NET Core 8.0 or later

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.

Support

For support and questions, please contact the AstreCode development team.

Changelog

See CHANGELOG.md for version history and changes.


AstreCode.Backend.Shared.API - Version 8.0.0

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 (1)

Showing the top 1 NuGet packages that depend on AstreCode.Backend.Shared.API:

Package Downloads
AstreCode.Backend.Shared.Infrastructure

The shared infrastructure project for AstreCode backend

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.1.4 199 12/3/2025
9.0.1.4 697 10/13/2025
9.0.1.3 171 10/13/2025
9.0.1.2 164 10/12/2025
9.0.1.1 158 10/12/2025
9.0.1 151 10/12/2025
9.0.0.9 159 10/12/2025
9.0.0.8 177 10/10/2025
9.0.0.6 169 10/9/2025
9.0.0.5 172 10/9/2025
9.0.0.4 1,101 9/9/2025
9.0.0.3 175 9/9/2025
9.0.0.2 183 9/9/2025
9.0.0.1 301 9/8/2025
9.0.0 180 9/8/2025
8.0.0 183 9/8/2025