proyecto preparado para DDD + CQRS
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using back.Domain;
|
||||
using MCVIngenieros.Healthchecks;
|
||||
using MediatR.Extensions.FluentValidation.AspNetCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenTelemetry.Logs;
|
||||
using OpenTelemetry.Metrics;
|
||||
using OpenTelemetry.Resources;
|
||||
@@ -43,7 +47,15 @@ public class Program
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Configuration.AddConfiguration(configuration);
|
||||
builder.Host.UseSerilog();
|
||||
// Add services to the container.
|
||||
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
||||
|
||||
builder.Services.AddMediatR(cfg =>
|
||||
{
|
||||
cfg.RegisterServicesFromAssembly(typeof(Program).Assembly);
|
||||
});
|
||||
|
||||
builder.Services.AddFluentValidation([typeof(Program).Assembly]);
|
||||
|
||||
builder.Services.AddHealthChecksSupport().DiscoverHealthChecks();
|
||||
builder.Services.AddLogging();
|
||||
builder.Logging.AddOpenTelemetry(options =>
|
||||
@@ -63,7 +75,32 @@ public class Program
|
||||
.AddAspNetCoreInstrumentation()
|
||||
.AddConsoleExporter());
|
||||
|
||||
builder.Services.AddDataProtection();
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddDefaultPolicy(policy =>
|
||||
{
|
||||
policy
|
||||
.WithOrigins(builder.Configuration.GetSection("AllowedHosts").Get<string[]>() ?? [])
|
||||
.SetIsOriginAllowedToAllowWildcardSubdomains()
|
||||
.SetPreflightMaxAge(TimeSpan.FromMinutes(10))
|
||||
.AllowCredentials()
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod();
|
||||
});
|
||||
});
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
builder.Services.AddAntiforgery(options =>
|
||||
{
|
||||
options.HeaderName = "X-XSRF-TOKEN";
|
||||
});
|
||||
|
||||
builder.Services.AddDbContext<ApplicationDbContext>(opts =>
|
||||
{
|
||||
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
|
||||
opts.UseSqlite(connectionString);
|
||||
});
|
||||
|
||||
builder.Services.AddControllers(options =>
|
||||
{
|
||||
@@ -88,7 +125,6 @@ public class Program
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
|
Reference in New Issue
Block a user