Revise CBB and remove unnecessary code
This commit is contained in:
		| @@ -1,25 +1,30 @@ | ||||
| using Core.Blueprint.KeyVault.Configuration; | ||||
| using Core.Blueprint.Logging.Configuration; | ||||
| using Core.Thalos.Adapters.Contracts; | ||||
| using Core.Thalos.Adapters.Extensions; | ||||
| using Core.Thalos.Adapters.Services; | ||||
| using Core.Thalos.BuildingBlocks.Authentication.Extensions; | ||||
| using Core.Thalos.BuildingBlocks; | ||||
| using Core.Thalos.BuildingBlocks.Configuration; | ||||
| using Core.Thalos.BuildingBlocks.Extensions; | ||||
| using Core.Thalos.External.ClientConfiguration; | ||||
| using Microsoft.AspNetCore.ResponseCompression; | ||||
| using OpenTelemetry.Logs; | ||||
| using OpenTelemetry.Resources; | ||||
| using Swashbuckle.AspNetCore.SwaggerUI; | ||||
| using System.IO.Compression; | ||||
| using System.Reflection; | ||||
|  | ||||
| var builder = WebApplication.CreateBuilder(args); | ||||
|  | ||||
| builder.Services.ConfigureAuthentication(builder.Configuration); | ||||
|  | ||||
| builder.Services.AddEndpointsApiExplorer(); | ||||
| builder.Configuration | ||||
|     .AddUserSecrets(Assembly.GetExecutingAssembly()) | ||||
|     .AddEnvironmentVariables(); | ||||
|  | ||||
| var services = builder.Services.AddKeyVault(builder.Configuration); | ||||
|  | ||||
| var authSettings = await AuthHelper.GetAuthSettings(builder.Services, builder, "thalos_common"); | ||||
|  | ||||
| builder.Services.ConfigureAuthentication(builder.Configuration, authSettings); | ||||
|  | ||||
| builder.Services.AddEndpointsApiExplorer(); | ||||
|  | ||||
|  | ||||
| builder.Services.AddResponseCompression(); | ||||
| builder.Services.AddProblemDetails(); | ||||
| builder.Services.AddLogs(builder); | ||||
| @@ -82,20 +87,13 @@ builder.Host.ConfigureServices((context, services) => | ||||
|     }); | ||||
|     services.AddResponseCaching(); | ||||
|     services.AddControllers(); | ||||
|     services.AddEndpointsApiExplorer(); | ||||
|     services.AddSwaggerGen(builder.Configuration); | ||||
|     services.AddSwaggerGen(builder.Configuration, "Core.Thalos.BFF.Api.xml", authSettings); | ||||
|     services.AddVersioning(builder.Configuration); | ||||
|     services.AddLogging(); | ||||
|     services.AddProblemDetails(); | ||||
|     services.AddHttpContextAccessor(); | ||||
|     services.AddTransient<TrackingMechanismExtension>(); // Register the TrackingIdHandler | ||||
|     services.RegisterExternalLayer(builder.Configuration); | ||||
|  | ||||
|     services.AddApiVersioning(options => options.ReportApiVersions = true) | ||||
|                    .AddApiExplorer(options => | ||||
|                    { | ||||
|                        options.GroupNameFormat = "'v'VVV"; | ||||
|                        options.SubstituteApiVersionInUrl = true; | ||||
|                    }); | ||||
| }); | ||||
|  | ||||
| builder.Services.AddCors(options => | ||||
| @@ -111,30 +109,35 @@ builder.Services.AddCors(options => | ||||
|  | ||||
| builder.Services.AddScoped<ITokenService, TokenService>(); | ||||
|  | ||||
| builder.Services.AddOutputCache(options => | ||||
| { | ||||
|     options.AddBasePolicy(builder => | ||||
|         builder.Expire(TimeSpan.FromSeconds(10))); | ||||
|     options.AddPolicy("Expire20", builder => | ||||
|         builder.Expire(TimeSpan.FromSeconds(20))); | ||||
|     options.AddPolicy("Expire30", builder => | ||||
|         builder.Expire(TimeSpan.FromSeconds(30))); | ||||
| }); | ||||
|  | ||||
| //*************************************************************************// | ||||
| var app = builder.Build(); | ||||
| app.UseLogging(builder.Configuration); | ||||
| app.UseSwaggerUI(builder.Configuration, authSettings); | ||||
| app.ConfigureSwagger(builder.Configuration); | ||||
|  | ||||
|  | ||||
| app.UseCors(options => options.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()); | ||||
| app.UseSwagger(); | ||||
| app.UseSwaggerUI(options => | ||||
| { | ||||
|     foreach (var version in app.DescribeApiVersions().Select(version => version.GroupName)) | ||||
|         options.SwaggerEndpoint($"/swagger/{version}/swagger.json", version); | ||||
|  | ||||
|     options.DisplayRequestDuration(); | ||||
|     options.EnableTryItOutByDefault(); | ||||
|     options.DocExpansion(DocExpansion.None); | ||||
| }); | ||||
| app.UseResponseCompression(); | ||||
| app.UseResponseCaching(); | ||||
| app.UseRouting(); | ||||
| app.UseCors(); | ||||
| app.UseHttpsRedirection(); | ||||
| app.UseStaticFiles(); | ||||
| app.UseResponseCompression(); | ||||
| app.UseOutputCache(); | ||||
| app.UseResponseCaching(); | ||||
|  | ||||
| app.UseAuthentication(); | ||||
| app.UseAuthorization(); | ||||
|  | ||||
| app.MapControllers(); | ||||
| app.UseHsts(); | ||||
| app.UseAntiforgery(); | ||||
| app.UseLogging(builder.Configuration); | ||||
| //app.MapHealthChecks("/health"); | ||||
|  | ||||
| app.Run(); | ||||
		Reference in New Issue
	
	Block a user