feat(backend): add DotEnv class for loading environment variables from .env file

This commit is contained in:
2026-03-04 15:11:25 -05:00
parent ac2f0a3dcf
commit 00233280d4
2 changed files with 25 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
namespace SharpbinV3.Server
{
/// <summary>
/// https://dusted.codes/dotenv-in-dotnet
/// </summary>
public static class DotEnv
{
public static void Load(string filePath)
{
if (!File.Exists(filePath))
return;
foreach (var line in File.ReadAllLines(filePath))
{
var parts = line.Split('=', StringSplitOptions.RemoveEmptyEntries);
if (parts.Length != 2)
continue;
Environment.SetEnvironmentVariable(parts[0], parts[1]);
}
}
}
}
+1
View File
@@ -24,6 +24,7 @@ namespace SharpbinV3.Server
{
public static void Main(string[] args)
{
DotEnv.Load(".env");
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.