diff --git a/Endpoint/Configuration/Core/Startup/ApiVersioningConfiguration.cs b/Endpoint/Configuration/Core/Startup/ApiVersioningConfiguration.cs index 151d5fb..1f60624 100644 --- a/Endpoint/Configuration/Core/Startup/ApiVersioningConfiguration.cs +++ b/Endpoint/Configuration/Core/Startup/ApiVersioningConfiguration.cs @@ -5,9 +5,9 @@ namespace Mirea.Api.Endpoint.Configuration.Core.Startup; public static class ApiVersioningConfiguration { - public static void AddCustomApiVersioning(this IServiceCollection services) + public static IApiVersioningBuilder AddCustomApiVersioning(this IServiceCollection services) { - services.AddApiVersioning(options => + return services.AddApiVersioning(options => { options.DefaultApiVersion = new ApiVersion(1, 0); options.AssumeDefaultVersionWhenUnspecified = true; diff --git a/Endpoint/Configuration/Core/Startup/JwtConfiguration.cs b/Endpoint/Configuration/Core/Startup/JwtConfiguration.cs index 191a328..c6009d0 100644 --- a/Endpoint/Configuration/Core/Startup/JwtConfiguration.cs +++ b/Endpoint/Configuration/Core/Startup/JwtConfiguration.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.IdentityModel.Tokens; @@ -11,7 +12,7 @@ namespace Mirea.Api.Endpoint.Configuration.Core.Startup; public static class JwtConfiguration { - public static IServiceCollection AddJwtToken(this IServiceCollection services, IConfiguration configuration) + public static AuthenticationBuilder AddJwtToken(this IServiceCollection services, IConfiguration configuration) { var lifeTimeJwt = TimeSpan.FromMinutes(int.Parse(configuration["SECURITY_LIFE_TIME_JWT"]!)); @@ -40,7 +41,7 @@ public static class JwtConfiguration SigningKey = jwtKey }); - services.AddAuthentication(options => + return services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; @@ -60,7 +61,5 @@ public static class JwtConfiguration TokenDecryptionKey = new SymmetricSecurityKey(jwtDecrypt) }; }); - - return services; } } diff --git a/Endpoint/Configuration/Core/Startup/LoggerConfiguration.cs b/Endpoint/Configuration/Core/Startup/LoggerConfiguration.cs index aece72b..a8e7f59 100644 --- a/Endpoint/Configuration/Core/Startup/LoggerConfiguration.cs +++ b/Endpoint/Configuration/Core/Startup/LoggerConfiguration.cs @@ -15,7 +15,7 @@ public static class LoggerConfiguration { public static IHostBuilder AddCustomSerilog(this IHostBuilder hostBuilder) { - hostBuilder.UseSerilog((context, _, configuration) => + return hostBuilder.UseSerilog((context, _, configuration) => { var generalConfig = context.Configuration.Get()?.LogSettings; configuration @@ -51,13 +51,11 @@ public static class LoggerConfiguration configuration.Filter.ByExcluding(Matching.WithProperty("SourceContext", sc => sc.Contains("Microsoft.EntityFrameworkCore.Database.Command"))); }); - - return hostBuilder; } public static IApplicationBuilder UseCustomSerilog(this IApplicationBuilder app) { - app.UseSerilogRequestLogging(options => + return app.UseSerilogRequestLogging(options => { options.MessageTemplate = "[{RequestMethod}] {RequestPath} [Client {RemoteIPAddress}] [{StatusCode}] in {Elapsed:0.0000} ms"; @@ -75,7 +73,5 @@ public static class LoggerConfiguration diagnosticContext.Set("RemoteIPAddress", httpContext.Connection.RemoteIpAddress?.ToString()); }; }); - - return app; } } diff --git a/Endpoint/Configuration/Core/Startup/SwaggerConfiguration.cs b/Endpoint/Configuration/Core/Startup/SwaggerConfiguration.cs index 1fc5b91..0eddcac 100644 --- a/Endpoint/Configuration/Core/Startup/SwaggerConfiguration.cs +++ b/Endpoint/Configuration/Core/Startup/SwaggerConfiguration.cs @@ -51,15 +51,13 @@ public static class SwaggerConfiguration options.IncludeXmlComments(Path.Combine(basePath, "ApiDtoDocs.xml")); }); - services.AddTransient, ConfigureSwaggerOptions>(); - - return services; + return services.AddTransient, ConfigureSwaggerOptions>(); } public static IApplicationBuilder UseCustomSwagger(this IApplicationBuilder app, IServiceProvider services) { app.UseSwagger(); - app.UseSwaggerUI(options => + return app.UseSwaggerUI(options => { options.InjectStylesheet($"{UrlHelper.GetSubPath}css/swagger/SwaggerDark.css"); var provider = services.GetService(); @@ -72,7 +70,5 @@ public static class SwaggerConfiguration options.RoutePrefix = UrlHelper.GetSubPathSwagger.Trim('/'); } }); - - return app; } } \ No newline at end of file