namespace FozFc.Api.Configuration; /// /// Strongly-typed application configuration, loaded from environment variables /// (the same names the docker-compose file provides). /// public sealed class AppOptions { public int Port { get; init; } = 4000; public string MongoUri { get; init; } = "mongodb://localhost:27017"; public string MongoDatabase { get; init; } = "foz_fc"; public string JwtSecret { get; init; } = "insecure-dev-secret-change-me-please-32chars"; public int JwtTtlSeconds { get; init; } = 60 * 60 * 24 * 30; public string[] CorsOrigins { get; init; } = Array.Empty(); public string FirebaseProjectId { get; init; } = string.Empty; public string PublicBaseUrl { get; init; } = "http://localhost:4000"; public bool AllowUnverifiedGoogle { get; init; } = false; public string SeedAdminEmail { get; init; } = "admin@foz.pt"; public string SeedAdminPassword { get; init; } = "admin123"; // ZeroZero feed (scrapes zerozero.pt directly; replaces the Cloudflare worker). public string RenderProxyUrl { get; init; } = ""; public string RenderProxySecret { get; init; } = ""; public const string JwtIssuer = "foz-fc"; public static AppOptions FromEnvironment() { static string Env(string key, string fallback = "") => Environment.GetEnvironmentVariable(key) is { Length: > 0 } v ? v : fallback; return new AppOptions { Port = int.TryParse(Env("PORT", "4000"), out var p) ? p : 4000, MongoUri = Env("MONGODB_URI", "mongodb://localhost:27017"), MongoDatabase = Env("MONGODB_DB", "foz_fc"), JwtSecret = Env("JWT_SECRET", "insecure-dev-secret-change-me-please-32chars"), JwtTtlSeconds = int.TryParse(Env("JWT_TTL_SECONDS", "2592000"), out var ttl) ? ttl : 2592000, CorsOrigins = Env("CORS_ORIGINS", "http://localhost:5173,http://localhost:8080,http://localhost:4173") .Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries), FirebaseProjectId = Env("FIREBASE_PROJECT_ID"), PublicBaseUrl = Env("PUBLIC_BASE_URL", "http://localhost:4000").TrimEnd('/'), AllowUnverifiedGoogle = Env("ALLOW_UNVERIFIED_GOOGLE", "false").Equals("true", StringComparison.OrdinalIgnoreCase), SeedAdminEmail = Env("SEED_ADMIN_EMAIL", "admin@foz.pt"), SeedAdminPassword = Env("SEED_ADMIN_PASSWORD", "admin123"), RenderProxyUrl = Env("RENDER_PROXY_URL"), RenderProxySecret = Env("RENDER_PROXY_SECRET"), }; } }