Feat: Cambios Varios 2
This commit is contained in:
@@ -4,6 +4,9 @@ using Microsoft.IdentityModel.Tokens;
|
||||
using SIGCM.Infrastructure;
|
||||
using SIGCM.Infrastructure.Data;
|
||||
using QuestPDF.Infrastructure;
|
||||
using FluentValidation;
|
||||
using FluentValidation.AspNetCore;
|
||||
using SIGCM.API.Middleware;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -11,9 +14,19 @@ QuestPDF.Settings.License = LicenseType.Community;
|
||||
|
||||
// 1. Agregar servicios al contenedor.
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddFluentValidationAutoValidation()
|
||||
.AddFluentValidationClientsideAdapters();
|
||||
// Registrar validadores manualmente si es necesario o por asamblea
|
||||
builder.Services.AddValidatorsFromAssemblyContaining<SIGCM.Application.Validators.CreateListingDtoValidator>();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
builder.Services.AddControllers()
|
||||
.AddJsonOptions(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase;
|
||||
});
|
||||
|
||||
// 2. Configurar Autenticación JWT
|
||||
var key = Encoding.ASCII.GetBytes(builder.Configuration["Jwt:Key"]!);
|
||||
|
||||
@@ -40,7 +53,7 @@ builder.Services.AddAuthentication(options =>
|
||||
});
|
||||
|
||||
// 3. Agregar Capa de Infraestructura
|
||||
builder.Services.AddInfrastructure();
|
||||
builder.Services.AddInfrastructure(builder.Configuration);
|
||||
|
||||
// 4. Configurar CORS
|
||||
builder.Services.AddCors(options =>
|
||||
@@ -49,7 +62,7 @@ builder.Services.AddCors(options =>
|
||||
policy =>
|
||||
{
|
||||
policy.WithOrigins(
|
||||
"http://localhost:5173",
|
||||
"http://localhost:5173",
|
||||
"http://localhost:5174",
|
||||
"http://localhost:5175",
|
||||
"http://localhost:5177")
|
||||
@@ -58,10 +71,14 @@ builder.Services.AddCors(options =>
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// --- Configuración del Pipeline HTTP ---
|
||||
|
||||
app.UseMiddleware<ExceptionMiddleware>();
|
||||
app.UseMiddleware<SecurityHeadersMiddleware>();
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
|
||||
Reference in New Issue
Block a user