TM.SecureApiKit 1.0.15

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

TM.SecureApiKit

Secure, Structured, and Production‑Ready Error Handling for ASP.NET Core

TM.SecureApiKit is a lightweight, configurable, and production‑ready middleware that provides secure, standardized, and structured error responses for ASP.NET Core APIs.

It helps developers deliver consistent error formats, improve debugging with trace IDs, and optionally hide sensitive exception details in production environments.


🚀 Features

  • Centralized error handling for ASP.NET Core APIs
  • Structured JSON error responses
  • Automatic inclusion of:
    • traceId
    • timestamp
    • path
    • method
    • status
  • Optional exposure of:
    • exception message
    • exception type
    • stack trace (for development)
  • Automatic exception → HTTP status mapping:
    • ArgumentException → 400
    • UnauthorizedAccessException → 403
    • KeyNotFoundException → 404
    • Others → 500
  • Customizable support contact (e.g., support email)
  • Zero external dependencies
  • Simple one‑line integration
  • Production‑ready and extensible

📦 Installation

Install via NuGet:

dotnet add package TM.SecureApiKit


Or via the NuGet Package Manager:

Install-Package TM.SecureApiKit

🛠 Usage
Add the middleware in your Program.cs or Startup.cs:
app.UseSecureErrorHandling();


With configuration:
app.UseSecureErrorHandling(options =>
{
    options.IncludeExceptionMessage = false; // Hide exception message in production
    options.IncludeExceptionType = false;    // Hide exception type
    options.IncludeExceptionDetails = false; // Hide stack trace
    options.SupportEmail = "support@myapp.com";
});




📄 Example Error Response
{
  "traceId": "0HNIGI2LC1B9E:00000001",
  "status": 500,
  "path": "/api/boom/boom",
  "method": "GET",
  "timestamp": "2025-12-11T21:05:33.123Z",
  "type": "Exception",
  "message": "Test error",
  "support": "support@myapp.com"
}



(Fields depend on your configuration.)

🧩 Why Use This Package?
- Makes your API error responses consistent
- Improves debugging with trace IDs and timestamps
- Avoids leaking sensitive information in production
- Reduces boilerplate code
- Works with any ASP.NET Core project
- Zero dependencies, minimal footprint

📚 Roadmap
- Add logging integration (Serilog, Microsoft.Extensions.Logging)
- Add environment‑based presets (Development / Production)
- Add custom exception mapping (e.g., NotFoundException → 404)
- Add correlation ID propagation
- Add ProblemDetails (RFC 7807) support

🤝 Contributing
Contributions are welcome.
Feel free to open issues or submit pull requests on GitHub.

📜 License
This project is licensed under the MIT License.
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 was computed.  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 was computed.  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
1.0.15 164 1/14/2026
1.0.14 148 1/14/2026
1.0.13 151 1/14/2026
1.0.12 147 1/14/2026
1.0.11 151 1/14/2026
1.0.10 148 1/14/2026
1.0.9 150 1/14/2026
1.0.8 154 1/14/2026
1.0.7 153 1/14/2026
1.0.6 154 1/14/2026
1.0.5 147 1/14/2026
1.0.4 153 1/14/2026
1.0.3 154 1/14/2026
1.0.2 155 1/10/2026