From 1bd1e342d38e32e40aa442b1c829f07cf2d7bd2d Mon Sep 17 00:00:00 2001 From: Leandro Hernan Rojas Date: Sat, 22 Mar 2025 01:19:48 -0300 Subject: [PATCH] Update StartUP --- .../Controllers/AuthenticationController.cs | 5 ++-- phronCare.API/Program.cs | 30 ++++++++++--------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/phronCare.API/Controllers/AuthenticationController.cs b/phronCare.API/Controllers/AuthenticationController.cs index 1e61035..0a9a970 100644 --- a/phronCare.API/Controllers/AuthenticationController.cs +++ b/phronCare.API/Controllers/AuthenticationController.cs @@ -32,6 +32,7 @@ namespace phronCare.API.Controllers #endregion + #region Segurity Endpoints [HttpPost] [Route("generate-qr-code")] public async Task GenerateQRCodeAsync() @@ -240,7 +241,7 @@ namespace phronCare.API.Controllers } return StatusCode(StatusCodes.Status500InternalServerError,"No se pudo encontrar el usuario, por favor intente nuevamente."); } - + #endregion #region GenerateAccess private async Task GenerateAccess(IdentityUser? user) { @@ -296,4 +297,4 @@ namespace phronCare.API.Controllers } #endregion } -} +} \ No newline at end of file diff --git a/phronCare.API/Program.cs b/phronCare.API/Program.cs index 38e7037..40175a1 100644 --- a/phronCare.API/Program.cs +++ b/phronCare.API/Program.cs @@ -16,33 +16,34 @@ using Services.Interfaces; using System.Text; var builder = WebApplication.CreateBuilder(args); -// Asegúrate de que el archivo appsettings.json se cargue correctamente + +#region AppSetting configuration +// Asegurar que el archivo appsettings.json se cargue correctamente builder.Configuration.SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); +#endregion -#region DbContext Identity Configuration +#region DbContext Identity Configuration and Operational var configuration = builder.Configuration; -builder.Services.AddDbContext(options => options.UseSqlServer(configuration.GetConnectionString("phronCareDB"))); +builder.Services.AddDbContext(options => options.UseSqlServer(configuration.GetConnectionString("phronCareDB"))); // DB Seguridad builder.Services.AddDbContext(options => - options.UseSqlServer(configuration.GetConnectionString("PhronCareOperationsHubConnection"))); + options.UseSqlServer(configuration.GetConnectionString("PhronCareOperationsHubConnection"))); // DB Operacional builder.Services.AddScoped(); builder.Services.AddScoped(); +#endregion -#endregion #region Require Confirmed Email -builder.Services.Configure( - opts => opts.SignIn.RequireConfirmedEmail = true - ); +builder.Services.Configure(opts => opts.SignIn.RequireConfirmedEmail = true); #endregion -#region Identity EF Configuration + +#region Security Identity EF Configuration builder.Services.AddIdentity() .AddEntityFrameworkStores() .AddDefaultTokenProviders(); -#endregion - builder.Services.Configure( opts => opts.TokenLifespan=TimeSpan.FromHours(10)); -builder.Services.AddSingleton(); +builder.Services.AddSingleton(); +#endregion #region Authentication Service @@ -80,7 +81,7 @@ builder.Services.AddSingleton(emailConfig); builder.Services.AddScoped(); #endregion -#region Swagger Authorization +#region Swagger Configuration builder.Services.AddSwaggerGen(option => { option.SwaggerDoc("v1", new OpenApiInfo { Title = "phronCARE API - SaludLAB", Version = "v1" }); @@ -110,7 +111,7 @@ builder.Services.AddSwaggerGen(option => }); #endregion -#region CORS SIN CAMBIOS +#region CORS sin cambios // builder.Services.AddCors(p => p.AddPolicy("CORS", builder => // { // builder @@ -156,4 +157,5 @@ app.UseAuthentication(); app.UseAuthorization(); app.UseHttpsRedirection(); app.MapControllers(); + app.Run(); \ No newline at end of file