diff --git a/Minecraft-Realms-Emulator/.gitignore b/Minecraft-Realms-Emulator/.gitignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/Minecraft-Realms-Emulator/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/Minecraft-Realms-Emulator/Minecraft-Realms-Emulator.csproj b/Minecraft-Realms-Emulator/Minecraft-Realms-Emulator.csproj index 44c0150..bcf19fb 100644 --- a/Minecraft-Realms-Emulator/Minecraft-Realms-Emulator.csproj +++ b/Minecraft-Realms-Emulator/Minecraft-Realms-Emulator.csproj @@ -9,6 +9,7 @@ + all diff --git a/Minecraft-Realms-Emulator/Program.cs b/Minecraft-Realms-Emulator/Program.cs index 0c4a572..c08b2a9 100644 --- a/Minecraft-Realms-Emulator/Program.cs +++ b/Minecraft-Realms-Emulator/Program.cs @@ -3,6 +3,13 @@ using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Helpers; var builder = WebApplication.CreateBuilder(args); +DotNetEnv.Env.Load(); + +if (Environment.GetEnvironmentVariable("CONNECTION_STRING") == null) +{ + Console.WriteLine("CONNECTION_STRING environment variable missing"); + return; +} // Add services to the container. @@ -13,7 +20,7 @@ builder.Services.AddSwaggerGen(); builder.Services.AddDbContext(options => { - options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")); + options.UseNpgsql(Environment.GetEnvironmentVariable("CONNECTION_STRING")); }); var app = builder.Build(); diff --git a/Minecraft-Realms-Emulator/appsettings.json b/Minecraft-Realms-Emulator/appsettings.json index 3ce2bc0..23160a4 100644 --- a/Minecraft-Realms-Emulator/appsettings.json +++ b/Minecraft-Realms-Emulator/appsettings.json @@ -1,7 +1,4 @@ { - "ConnectionStrings": { - "DefaultConnection": "User Id=postgres.aquqykciubzfolgrftwa;Password=z6hmYsiCl0f7HzUr;Server=aws-0-us-west-1.pooler.supabase.com;Port=5432;Database=postgres" - }, "Logging": { "LogLevel": { "Default": "Information",