mirror of
https://github.com/CyberL1/Minecraft-Realms-Emulator.git
synced 2024-12-22 04:18:21 -05:00
feat: dotenv
This commit is contained in:
parent
408578e098
commit
fe6a66601d
1
Minecraft-Realms-Emulator/.gitignore
vendored
Normal file
1
Minecraft-Realms-Emulator/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.env
|
@ -9,6 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DotNetEnv" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
@ -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<DataContext>(options =>
|
||||
{
|
||||
options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection"));
|
||||
options.UseNpgsql(Environment.GetEnvironmentVariable("CONNECTION_STRING"));
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user