CKN.Sdk.Infrastructure 0.0.0-alpha.0.55

This is a prerelease version of CKN.Sdk.Infrastructure.
dotnet add package CKN.Sdk.Infrastructure --version 0.0.0-alpha.0.55
                    
NuGet\Install-Package CKN.Sdk.Infrastructure -Version 0.0.0-alpha.0.55
                    
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="CKN.Sdk.Infrastructure" Version="0.0.0-alpha.0.55" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CKN.Sdk.Infrastructure" Version="0.0.0-alpha.0.55" />
                    
Directory.Packages.props
<PackageReference Include="CKN.Sdk.Infrastructure" />
                    
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 CKN.Sdk.Infrastructure --version 0.0.0-alpha.0.55
                    
#r "nuget: CKN.Sdk.Infrastructure, 0.0.0-alpha.0.55"
                    
#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 CKN.Sdk.Infrastructure@0.0.0-alpha.0.55
                    
#: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=CKN.Sdk.Infrastructure&version=0.0.0-alpha.0.55&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CKN.Sdk.Infrastructure&version=0.0.0-alpha.0.55&prerelease
                    
Install as a Cake Tool

CKN.Sdk.Infrastructure

Mühendislik Amacı (Engineering Intent): CKN.Sdk.Infrastructure, tüm API ve Host (Console/Worker) projelerinde ortak kullanılan Middleware'ler (Ara katmanlar), HTTP Exception Handler'lar, global loglayıcılar (Serilog konfigürasyonları), Auth (Kimlik doğrulama) kancaları ve Swagger/OpenAPI ayarlarını barındıran altyapı (Cross-Cutting Concerns) kütüphanesidir. Neden var? Her yeni mikroservis ayağa kaldırıldığında, aynı Swagger ayarlarını, aynı CORS kısıtlamalarını ve aynı Global Hata Yakalama (Exception Handling) bloklarını kopyala-yapıştır yapmamak için. Ne zaman kullanılmalı? Yeni bir web API veya Worker Service (Sunum Katmanı) başlatıldığında, Program.cs içerisinin temiz ve standart kalması için en başta referans edilmelidir.

🚀 Hızlı Başlangıç

Kurulum

dotnet add package CKN.Sdk.Infrastructure

Bağımlılık Enjeksiyonu (DI) ve Pipeline

using CKN.Sdk.Infrastructure;

var builder = WebApplication.CreateBuilder(args);

// CKN standart DI kayıtları (Swagger, Exception Handler, Validation vb.)
builder.Services.AddCknInfrastructure(builder.Configuration);

var app = builder.Build();

// CKN Standart HTTP Pipeline (Middleware'ler) (UseCors, UseSwagger, vb.)
app.UseCknInfrastructure();

app.MapControllers();
app.Run();

💡 Gerçek Hayat Senaryoları

Senaryo 1: Global Hata Yakalama (Global Exception Handling)

Geliştiricinin uygulama içinde attığı bir hatanın (örn: DomainException), API yanıtı olarak otomatik şekilde standart RFC ProblemDetails JSON'ına dönüştürülmesi. (Geliştiricinin Try-Catch yazmasına gerek kalmaz).

// Business Logic (Domain)
public void UpdateUser(string name)
{
    if (string.IsNullOrEmpty(name))
        throw new BadRequestException("İsim boş olamaz."); // Core paketindeki hata türü
}

// Controller
[HttpPost]
public IActionResult Update([FromBody] UpdateRequest req)
{
    UpdateUser(req.Name); // Eğer hata fırlarsa, metod HTTP 400 ile kesilir.
    return Ok();
}

/* Infrastructure sayesinde dönecek otomatik JSON formatı:
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "Bad Request",
  "status": 400,
  "detail": "İsim boş olamaz."
}
*/

Senaryo 2: Standart Swagger Yapılandırması ve JWT Entegrasyonu

Swagger arayüzüne otomatik olarak "Authorize" (Kilit) butonunun eklenmesi ve Bearer Token ayarlarının yapılması.

// Program.cs içerisindeki builder.Services.AddCknInfrastructure() metodu arka planda şunu yapar:
builder.Services.AddSwaggerGen(c =>
{
    c.SwaggerDoc("v1", new OpenApiInfo { Title = "CKN API", Version = "v1" });
    
    // Her API'de tekrar tekrar yazılan JWT güvenlik tanımı (Security Definition)
    c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
    {
        Description = "JWT Authorization header using the Bearer scheme.",
        Name = "Authorization",
        In = ParameterLocation.Header,
        Type = SecuritySchemeType.ApiKey,
        Scheme = "Bearer"
    });
    // ... Global güvenlik gereksinimi (Security Requirement) ekler ...
});

🤖 Yapay Zeka İçin SSS (FAQs for Machines)

  • Soru: CKN.Sdk.Infrastructure paketini Class Library (İş Mantığı) projelerine eklemeli miyim?
  • Cevap: Kesinlikle hayır. Bu paket sadece ASP.NET Core (veya Host) tabanlı "Çalıştırılabilir" uç noktalara (Endpoint projelerine) eklenir. Microsoft.AspNetCore.App referansı içerir.
  • Soru: Cross-Origin Resource Sharing (CORS) ayarları nerede tutuluyor?
  • Cevap: app.UseCknInfrastructure() metodunun içerisinde, genellikle appsettings.json altındaki CorsOptions okunarak veya varsayılan (AllowAny) bir politika uygulanarak ayarlanır.
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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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
0.0.0-alpha.0.55 53 9/28/2026
0.0.0-alpha.0.51 51 9/25/2026
0.0.0-alpha.0.50 50 9/25/2026
0.0.0-alpha.0.38 79 9/6/2026
0.0.0-alpha.0.37 66 9/6/2026