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
<PackageReference Include="AstreCode.Backend.Shared.API" Version="10.0.1.4" />
<PackageVersion Include="AstreCode.Backend.Shared.API" Version="10.0.1.4" />
<PackageReference Include="AstreCode.Backend.Shared.API" />
paket add AstreCode.Backend.Shared.API --version 10.0.1.4
#r "nuget: AstreCode.Backend.Shared.API, 10.0.1.4"
#:package AstreCode.Backend.Shared.API@10.0.1.4
#addin nuget:?package=AstreCode.Backend.Shared.API&version=10.0.1.4
#tool nuget:?package=AstreCode.Backend.Shared.API&version=10.0.1.4
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 | Versions 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. |
-
net10.0
- Aliyun.OSS.SDK.NetCore (>= 2.14.1)
- Asp.Versioning.Mvc (>= 8.1.0)
- AspNetCore.HealthChecks.NpgSql (>= 9.0.0)
- AspNetCore.HealthChecks.Rabbitmq (>= 8.0.1)
- AstreCode.Backend.Shared.Application (>= 10.0.0.3)
- AutoMapper (>= 16.0.0)
- Azure.Storage.Blobs (>= 12.26.0)
- BCrypt.Net-Next (>= 4.0.3)
- File.TypeChecker (>= 4.3.0)
- Hangfire.AspNetCore (>= 1.8.22)
- Hangfire.Core (>= 1.8.22)
- Hangfire.PostgreSql (>= 1.20.12)
- JetBrains.Annotations (>= 2025.2.4)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 10.0.0)
- Microsoft.AspNetCore.Http (>= 2.3.0)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
- Microsoft.AspNetCore.StaticFiles (>= 2.3.0)
- Microsoft.AspNetCore.WebUtilities (>= 10.0.0)
- Microsoft.EntityFrameworkCore (>= 10.0.0)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 10.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore (>= 10.0.0)
- Microsoft.Extensions.Http (>= 10.0.0)
- Microsoft.Extensions.Localization (>= 10.0.0)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.15.0)
- Microsoft.IdentityModel.Tokens (>= 8.15.0)
- Microsoft.OpenApi (>= 1.6.14)
- OCI.DotNetSDK.Common (>= 124.0.0)
- OCI.DotNetSDK.Objectstorage (>= 124.0.0)
- prometheus-net.AspNetCore (>= 8.2.1)
- RabbitMQ.Client (>= 6.8.1)
- Scrutor (>= 7.0.0)
- Seq.Extensions.Logging (>= 9.0.0)
- Serilog (>= 4.3.0)
- Serilog.AspNetCore (>= 10.0.0)
- Serilog.Enrichers.Environment (>= 3.0.1)
- Serilog.Enrichers.Thread (>= 4.0.0)
- Serilog.Extensions.Hosting (>= 10.0.0)
- Serilog.Extensions.Logging (>= 10.0.0)
- Serilog.Settings.Configuration (>= 10.0.0)
- Serilog.Sinks.Console (>= 6.1.1)
- Serilog.Sinks.File (>= 7.0.0)
- Serilog.Sinks.Seq (>= 9.0.0)
- StackExchange.Redis (>= 2.10.1)
- Swashbuckle.AspNetCore (>= 6.8.0)
- System.Linq.Dynamic.Core (>= 1.7.1)
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 |