feat: adaptación de los proyectos para utilizar .env y comienzo de preparación para despliegue en docker
This commit is contained in:
		@@ -113,5 +113,39 @@ namespace Mercados.Api.Controllers
 | 
			
		||||
                return StatusCode(500, "Ocurrió un error interno en el servidor.");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [HttpGet("agroganadero/history")]
 | 
			
		||||
        [ProducesResponseType(typeof(IEnumerable<CotizacionGanado>), StatusCodes.Status200OK)]
 | 
			
		||||
        [ProducesResponseType(StatusCodes.Status500InternalServerError)]
 | 
			
		||||
        public async Task<IActionResult> GetAgroganaderoHistory([FromQuery] string categoria, [FromQuery] string especificaciones, [FromQuery] int dias = 30)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                var data = await _ganadoRepo.ObtenerHistorialAsync(categoria, especificaciones, dias);
 | 
			
		||||
                return Ok(data);
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogError(ex, "Error al obtener historial para la categoría {Categoria}.", categoria);
 | 
			
		||||
                return StatusCode(500, "Ocurrió un error interno en el servidor.");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [HttpGet("granos/history/{nombre}")]
 | 
			
		||||
        [ProducesResponseType(typeof(IEnumerable<CotizacionGrano>), StatusCodes.Status200OK)]
 | 
			
		||||
        [ProducesResponseType(StatusCodes.Status500InternalServerError)]
 | 
			
		||||
        public async Task<IActionResult> GetGranoHistory(string nombre, [FromQuery] int dias = 30)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                var data = await _granoRepo.ObtenerHistorialAsync(nombre, dias);
 | 
			
		||||
                return Ok(data);
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogError(ex, "Error al obtener historial para el grano {Grano}.", nombre);
 | 
			
		||||
                return StatusCode(500, "Ocurrió un error interno en el servidor.");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -7,6 +7,7 @@
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <PackageReference Include="DotNetEnv" Version="3.1.1" />
 | 
			
		||||
    <PackageReference Include="FluentMigrator.Runner" Version="7.1.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.5" />
 | 
			
		||||
    <PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.1" />
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,9 @@ using Mercados.Infrastructure.Persistence;
 | 
			
		||||
using Mercados.Infrastructure.Persistence.Repositories;
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
 | 
			
		||||
// Carga las variables de entorno desde el archivo .env en la raíz de la solución.
 | 
			
		||||
DotNetEnv.Env.Load();
 | 
			
		||||
 | 
			
		||||
var builder = WebApplication.CreateBuilder(args);
 | 
			
		||||
 | 
			
		||||
// Nombre para política de CORS
 | 
			
		||||
@@ -16,7 +19,10 @@ builder.Services.AddCors(options =>
 | 
			
		||||
    options.AddPolicy(name: MyAllowSpecificOrigins,
 | 
			
		||||
                      policy =>
 | 
			
		||||
                      {
 | 
			
		||||
                          policy.WithOrigins("http://localhost:5173", "http://192.168.10.78:5173")
 | 
			
		||||
                          policy.WithOrigins("http://localhost:5173", // Desarrollo Frontend
 | 
			
		||||
                                "http://192.168.10.78:5173", // Desarrollo en Red Local
 | 
			
		||||
                                "https://www.eldia.com" // <--- DOMINIO DE PRODUCCIÓN
 | 
			
		||||
                                )
 | 
			
		||||
                                .AllowAnyHeader()
 | 
			
		||||
                                .AllowAnyMethod();
 | 
			
		||||
                      });
 | 
			
		||||
 
 | 
			
		||||
@@ -7,13 +7,13 @@
 | 
			
		||||
  },
 | 
			
		||||
  "AllowedHosts": "*",
 | 
			
		||||
  "ConnectionStrings": {
 | 
			
		||||
    "DefaultConnection": "Server=TECNICA3;Database=MercadosDb;User Id=mercadosuser;Password=@mercados1351@;Trusted_Connection=False;Encrypt=False;"
 | 
			
		||||
    "DefaultConnection": ""
 | 
			
		||||
  },
 | 
			
		||||
  "ApiKeys": {
 | 
			
		||||
    "Finnhub": "cuvhr0hr01qs9e81st2gcuvhr0hr01qs9e81st30",
 | 
			
		||||
    "Finnhub": "",
 | 
			
		||||
    "Bcr": {
 | 
			
		||||
      "Key": "D1782A51-A5FD-EF11-9445-00155D09E201",
 | 
			
		||||
      "Secret": "da96378186bc5a256fa821fbe79261ec7172dec283214da0aacca41c640f80e3"
 | 
			
		||||
      "Key": "",
 | 
			
		||||
      "Secret": ""
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user