mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
69 lines
1.8 KiB
C#
69 lines
1.8 KiB
C#
// Load a local .env file into environment variables when present (useful for local development)
|
|
try
|
|
{
|
|
var envPath = Path.Combine(Directory.GetCurrentDirectory(), ".env");
|
|
if (File.Exists(envPath))
|
|
{
|
|
foreach (var line in File.ReadAllLines(envPath))
|
|
{
|
|
var trimmed = line.Trim();
|
|
if (string.IsNullOrEmpty(trimmed) || trimmed.StartsWith("#"))
|
|
continue;
|
|
var idx = trimmed.IndexOf('=');
|
|
if (idx <= 0)
|
|
continue;
|
|
var key = trimmed.Substring(0, idx).Trim();
|
|
var val = trimmed.Substring(idx + 1).Trim();
|
|
if (val.Length >= 2 && ((val.StartsWith("\"") && val.EndsWith("\"")) || (val.StartsWith("'") && val.EndsWith("'"))))
|
|
{
|
|
val = val.Substring(1, val.Length - 2);
|
|
}
|
|
if (Environment.GetEnvironmentVariable(key) == null)
|
|
Environment.SetEnvironmentVariable(key, val);
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
// If dotenv loading fails, continue without blocking startup.
|
|
}
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
|
builder.Services.AddControllers();
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
builder.Services.AddOpenApi();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
app.MapOpenApi();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
var summaries = new[]
|
|
{
|
|
"Freezing",
|
|
"Bracing",
|
|
"Chilly",
|
|
"Cool",
|
|
"Mild",
|
|
"Warm",
|
|
"Balmy",
|
|
"Hot",
|
|
"Sweltering",
|
|
"Scorching",
|
|
};
|
|
|
|
app.MapControllers();
|
|
app.Run();
|
|
|