diff --git a/Endpoint/Program.cs b/Endpoint/Program.cs index c864599..4e5d4c6 100644 --- a/Endpoint/Program.cs +++ b/Endpoint/Program.cs @@ -6,9 +6,26 @@ namespace Mirea.Api.Endpoint; public class Program { + private static IConfigurationRoot ConfigureEnvironment() + { + EnvironmentManager.LoadEnvironment(".env"); + var environmentVariables = Environment.GetEnvironmentVariables() + .OfType() + .ToDictionary( + entry => entry.Key.ToString() ?? string.Empty, + entry => entry.Value?.ToString() ?? string.Empty + ); + + var result = new ConfigurationBuilder().AddInMemoryCollection(environmentVariables!); + + return result.Build(); + } + public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); + builder.Configuration.AddConfiguration(ConfigureEnvironment()); + builder.Configuration.AddJsonFile(Settings.FilePath, optional: true, reloadOnChange: true); // Add services to the container.