StoneKit.Infrastructure
2024.1.1.261630
See the version list below for details.
dotnet add package StoneKit.Infrastructure --version 2024.1.1.261630
NuGet\Install-Package StoneKit.Infrastructure -Version 2024.1.1.261630
<PackageReference Include="StoneKit.Infrastructure" Version="2024.1.1.261630" />
paket add StoneKit.Infrastructure --version 2024.1.1.261630
#r "nuget: StoneKit.Infrastructure, 2024.1.1.261630"
// Install StoneKit.Infrastructure as a Cake Addin #addin nuget:?package=StoneKit.Infrastructure&version=2024.1.1.261630 // Install StoneKit.Infrastructure as a Cake Tool #tool nuget:?package=StoneKit.Infrastructure&version=2024.1.1.261630
StoneKit Infrastructure
StoneKit Infrastructure is a comprehensive boilerplate for starting new ASP.NET Core 8 API projects. It integrates essential libraries and services, including FluentValidation, Serilog logging, hashing, HttpClient, OpenAPI documentation, and more, to streamline the setup and development process.
Installation
You can install StoneKit.Infrastructure via NuGet Package Manager:
PM> Install-Package StoneKit.Infrastructure
Features
Logging:
- Integrates Serilog for robust and flexible logging.
Validation:
- Incorporates FluentValidation for model validation.
Hashing:
- Provides hashing utilities for secure data hashing.
HTTP Client:
- Configures HttpClient for making HTTP requests.
OpenAPI Documentation:
- Configures Swagger and SwaggerUI for API documentation.
CORS Configuration:
- Allows easy setup of CORS policies.
Middleware:
- Includes custom middleware for exception handling and initialization.
- Adds various security-related middlewares (e.g., no-cache headers, redirect validation).
SignalR:
- Configures SignalR with environment-specific settings.
Dependency Injection:
- Registers necessary services and middlewares for dependency injection.
Controller Configuration:
- Sets up controllers with Newtonsoft.Json for JSON serialization.
Security:
- Adds multiple security headers and policies.
Usage
Setting up your project
Configure Services:
In your
Program.cs
, use theConfigureServices
method to configure all necessary services.using Microsoft.Extensions.Configuration; var builder = WebApplication.CreateBuilder(args); var configOptions = new AppConfigurationOptions { // Set your options here }; builder.ConfigureServices(configOptions); var app = builder.BuildApp(configOptions); app.Run();
App Configuration Options:
Define your configuration options to customize the setup.
public class AppConfigurationOptions : BaseConfiguration { // Define properties like AppName, SerilogOptions, OpenApiOptions, etc. }
FluentValidation:
Add validators to your project by inheriting from
AbstractValidator<T>
and ensure they are in the configured assembly.using FluentValidation; public class SampleModelValidator : AbstractValidator<SampleModel> { public SampleModelValidator() { RuleFor(x => x.Property).NotEmpty(); } }
Example Middleware
public class ExceptionHandlerMiddleware : IMiddleware
{
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
try
{
await next(context);
}
catch (Exception ex)
{
// Handle exception
}
}
}
Adding Hashing Utility
public interface IHasher
{
string Hash(string input);
}
public class Hasher : IHasher
{
public string Hash(string input)
{
using var sha256 = SHA256.Create();
var bytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(input));
return Convert.ToBase64String(bytes);
}
}
Configuring OpenAPI
public static void ConfigureOpenApi(this WebApplicationBuilder builder, string appName, OpenApiOptions options, Assembly validatorAssembly)
{
// OpenAPI configuration logic
}
Contributions
Contributions and feedback are welcome! Feel free to submit issues, feature requests, or pull requests on the GitHub repository.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Product | Versions 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. |
-
net8.0
- FluentValidation (>= 11.9.2)
- JetBrains.Annotations (>= 2023.3.0)
- Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 8.0.6)
- Microsoft.Data.SqlClient (>= 5.2.1)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 8.0.6)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- Microsoft.OpenApi (>= 1.6.15)
- Newtonsoft.Json (>= 13.0.3)
- NWebsec.AspNetCore.Core (>= 3.0.1)
- NWebsec.AspNetCore.Middleware (>= 3.0.0)
- Serilog (>= 4.0.0)
- Serilog.AspNetCore (>= 8.0.1)
- StoneKit.TransverseMapper (>= 1.24.703.180757)
- Swashbuckle.AspNetCore (>= 6.6.2)
- Swashbuckle.AspNetCore.Filters (>= 8.0.2)
- Swashbuckle.AspNetCore.Swagger (>= 6.6.2)
- Swashbuckle.AspNetCore.SwaggerGen (>= 6.6.2)
- Swashbuckle.AspNetCore.SwaggerUI (>= 6.6.2)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on StoneKit.Infrastructure:
Package | Downloads |
---|---|
StoneKit.Trustee.Host
rtwert |
|
StoneKit.Trustee.Providers.AzureKeyVault
Package Description |
|
StoneKit.Trustee.Providers.FileSystem
Package Description |
|
StoneKit.Trustee.Providers.HashicorpVault
Package Description |
|
StoneKit.Trustee.Providers.Git
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2024.1.1.391401 | 85 | 10/5/2024 |
2024.1.1.305385 | 130 | 8/5/2024 |
2024.1.1.268769 | 103 | 7/9/2024 |
2024.1.1.261674 | 104 | 7/4/2024 |
2024.1.1.261665 | 100 | 7/4/2024 |
2024.1.1.261630 | 116 | 7/4/2024 |
2024.1.1.260673 | 116 | 7/3/2024 |
2024.1.1.260489 | 109 | 7/3/2024 |
2024.1.1.260485 | 102 | 7/3/2024 |
1.24.703.180801 | 478 | 7/3/2024 |
1.24.703.164607 | 355 | 7/3/2024 |
1.24.703.121215 | 188 | 7/3/2024 |
1.24.626.192714 | 89 | 6/26/2024 |
1.24.612.917 | 88 | 6/11/2024 |
1.24.611.233128 | 85 | 6/11/2024 |
1.24.611.232751 | 93 | 6/11/2024 |
1.24.603.121931 | 499 | 6/3/2024 |