2025-02-13 13:52:02 +02:00
|
|
|
using DevOpsProject.CommunicationControl.API.DI;
|
|
|
|
using DevOpsProject.CommunicationControl.API.Middleware;
|
2025-02-16 22:15:22 +02:00
|
|
|
using Microsoft.OpenApi.Models;
|
2025-02-13 13:52:02 +02:00
|
|
|
using Serilog;
|
|
|
|
|
|
|
|
internal class Program
|
|
|
|
{
|
|
|
|
private static void Main(string[] args)
|
|
|
|
{
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
builder.Host.UseSerilog((context, services, loggerConfig) =>
|
|
|
|
loggerConfig.ReadFrom.Configuration(context.Configuration)
|
|
|
|
.ReadFrom.Services(services)
|
|
|
|
.Enrich.FromLogContext());
|
|
|
|
|
2025-02-19 23:02:15 +02:00
|
|
|
builder.Services.AddApiVersioningConfiguration();
|
2025-02-16 22:15:22 +02:00
|
|
|
|
|
|
|
// TODO: consider this approach
|
2025-02-19 23:02:15 +02:00
|
|
|
builder.Services.AddJsonControllerOptionsConfiguration();
|
|
|
|
|
2025-02-13 13:52:02 +02:00
|
|
|
builder.Services.AddEndpointsApiExplorer();
|
2025-02-16 22:15:22 +02:00
|
|
|
builder.Services.AddSwaggerGen(c =>
|
|
|
|
{
|
|
|
|
c.SwaggerDoc("v1", new OpenApiInfo { Title = "CommunicationControl - V1", Version = "v1.0" });
|
|
|
|
});
|
2025-02-13 13:52:02 +02:00
|
|
|
|
|
|
|
// TODO: LATER - ADD OpenTelemtry
|
|
|
|
|
|
|
|
builder.Services.AddRedis(builder.Configuration);
|
|
|
|
builder.Services.AddCommunicationControlLogic();
|
|
|
|
|
2025-02-19 23:02:15 +02:00
|
|
|
builder.Services.AddOptionsConfiguration(builder.Configuration);
|
2025-02-13 13:52:02 +02:00
|
|
|
|
2025-02-19 23:02:15 +02:00
|
|
|
builder.Services.AddHttpClientsConfiguration();
|
2025-02-13 13:52:02 +02:00
|
|
|
|
|
|
|
var corsPolicyName = "AllowReactApp";
|
2025-02-19 23:02:15 +02:00
|
|
|
builder.Services.AddCorsConfiguration(corsPolicyName);
|
2025-02-13 13:52:02 +02:00
|
|
|
|
|
|
|
builder.Services.AddExceptionHandler<ExceptionHandlingMiddleware>();
|
|
|
|
builder.Services.AddProblemDetails();
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
app.UseExceptionHandler();
|
|
|
|
|
2025-03-12 00:24:56 +02:00
|
|
|
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI();
|
2025-02-13 13:52:02 +02:00
|
|
|
|
|
|
|
app.UseCors(corsPolicyName);
|
|
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
app.MapControllers();
|
|
|
|
|
|
|
|
app.Run();
|
|
|
|
}
|
|
|
|
}
|