Configure ASP.NET for the API to work #7

Merged
Wesser merged 17 commits from feat/setting-up-asp into release/v1.0.0 2024-01-26 20:41:01 +03:00
Showing only changes of commit e6cc9437d5 - Show all commits

View File

@ -6,9 +6,26 @@ namespace Mirea.Api.Endpoint;
public class Program public class Program
{ {
private static IConfigurationRoot ConfigureEnvironment()
{
EnvironmentManager.LoadEnvironment(".env");
var environmentVariables = Environment.GetEnvironmentVariables()
.OfType<DictionaryEntry>()
.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) public static void Main(string[] args)
{ {
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddConfiguration(ConfigureEnvironment());
builder.Configuration.AddJsonFile(Settings.FilePath, optional: true, reloadOnChange: true);
// Add services to the container. // Add services to the container.