82 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			82 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using Core.Blueprint.DAL.Mongo.Configuration;
 | |
| using Core.Blueprint.Logging.Configuration;
 | |
| using Core.Blueprint.Redis.Configuration;
 | |
| using Core.Inventory.DAL.API.Extensions;
 | |
| using Core.Inventory.Provider;
 | |
| using Microsoft.AspNetCore.HttpLogging;
 | |
| using System.Reflection;
 | |
| using System.Text.Json.Serialization;
 | |
| 
 | |
| var builder = WebApplication.CreateBuilder(args);
 | |
| 
 | |
| builder.Services.AddEndpointsApiExplorer();
 | |
| builder.Services.AddSwaggerGen();
 | |
| builder.Configuration
 | |
|     .AddUserSecrets(Assembly.GetExecutingAssembly())
 | |
|     .AddEnvironmentVariables();
 | |
| 
 | |
| builder.Services.AddResponseCompression();
 | |
| builder.Services.AddProblemDetails();
 | |
| builder.Services.AddMemoryCache();
 | |
| builder.Services.AddLogs(builder);
 | |
| builder.Services.AddRedis(builder.Configuration);
 | |
| builder.Services.AddMongoLayer(builder.Configuration);
 | |
| builder.Services.AddDALLayerServices(builder.Configuration);
 | |
| 
 | |
| builder.Host.ConfigureServices((context, services) =>
 | |
| {
 | |
| 
 | |
|     services.AddLogging();
 | |
|     services.AddControllers();
 | |
|     services.AddProblemDetails();
 | |
|     services.AddCors(options
 | |
|         => options.AddDefaultPolicy(policyBuilder
 | |
|             => policyBuilder
 | |
|                 .AllowAnyOrigin()
 | |
|                 .AllowAnyHeader()
 | |
|                 .AllowAnyMethod()));
 | |
| 
 | |
|     builder.Services.Configure<Microsoft.AspNetCore.Http.Json.JsonOptions>(options =>
 | |
|     {
 | |
|         options.SerializerOptions.Converters.Add(new JsonStringEnumConverter());
 | |
|     });
 | |
| 
 | |
|     services
 | |
|         .AddEndpointsApiExplorer()
 | |
|         .AddVersioning()
 | |
|         .AddSwagger();
 | |
| 
 | |
|     services.AddHealthChecks();
 | |
|     services.AddHttpLogging(options => options.LoggingFields = HttpLoggingFields.All);
 | |
| 
 | |
|     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.UseSwagger();
 | |
| app.UseSwaggerUI();
 | |
| app.UseAuthentication();
 | |
| app.UseAuthorization();
 | |
| app.MapControllers();
 | |
| app.UseCors();
 | |
| app.ConfigureSwagger();
 | |
| app.UseHttpsRedirection();
 | |
| app.UseStaticFiles();
 | |
| app.UseRouting();
 | |
| app.UseResponseCompression();
 | |
| app.UseOutputCache();
 | |
| app.UseResponseCaching();
 | |
| app.UseLogging(builder.Configuration);
 | |
| app.MapHealthChecks("/health");
 | |
| 
 | |
| app.Run();
 | 
