First version of BFF

This commit is contained in:
2025-06-23 01:55:17 -06:00
parent e8a8af0228
commit 3e8100e1c5
28 changed files with 865 additions and 61 deletions

View File

@@ -0,0 +1,19 @@
using Core.Blueprint.External;
namespace Core.Inventory.External.GatewayConfigurations
{
public record GatewayConfiguration
{
public GatewayConfiguration()
{
InventoryService = new InventoryServiceAPI();
}
public InventoryServiceAPI InventoryService { get; set; }
}
public record InventoryServiceAPI
{
public string Channel { get; set; }
public BaseEndpoint Endpoint { get; set; }
}
}

View File

@@ -0,0 +1,48 @@
using Core.Blueprint.External;
using Microsoft.Extensions.Configuration;
namespace Core.Inventory.External.GatewayConfigurations
{
public class GatewaySettingsConfigurations
{
private static GatewayConfiguration GatewayConfigurations { get; set; } = new GatewayConfiguration();
private readonly IConfiguration _configuration;
public GatewaySettingsConfigurations(IConfiguration configuration)
{
_configuration = configuration;
SetDashboardServiceAPIEndpoint();
}
public static InventoryServiceAPI GetInventoryServiceAPIEndpoint()
{
return GatewayConfigurations.InventoryService;
}
private GatewayConfiguration SetDashboardServiceAPIEndpoint()
{
IConfigurationSection source;
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? string.Empty;
if (environment == "Local")
source = _configuration.GetSection("LocalGateways");
else
source = _configuration.GetSection("Gateways");
var endpoint = source["InventoryService"] ?? string.Empty;
if (string.IsNullOrEmpty(endpoint)) throw new Exception("Inventory Service endpoint is empty or null");
GatewayConfigurations.InventoryService = new InventoryServiceAPI()
{
Endpoint = new BaseEndpoint()
{
Uri = new Uri(endpoint),
Url = endpoint,
Token = string.Empty,
APIName = "Inventory Service"
}
};
return GatewayConfigurations;
}
}
}