From d0e594c35952e320390d58dff4f13015c2cb1a00 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 14 Jun 2026 18:30:15 +0100 Subject: [PATCH] synchro with main --- src/Yavsc.Server/Helpers/ConfigHelpers.cs | 18 ++++++++++++++++++ src/Yavsc.Web/Program.cs | 6 ++---- src/Yavsc.Web/Yavsc.Web.csproj | 3 ++- 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 src/Yavsc.Server/Helpers/ConfigHelpers.cs diff --git a/src/Yavsc.Server/Helpers/ConfigHelpers.cs b/src/Yavsc.Server/Helpers/ConfigHelpers.cs new file mode 100644 index 00000000..1475ccdc --- /dev/null +++ b/src/Yavsc.Server/Helpers/ConfigHelpers.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Configuration; + +namespace Yavsc.Server.Helpers; + +public static class ConfigHelpers +{ + public static void AddConfiguration(this WebApplicationBuilder builder, string appName ) + { + var rootConfig = builder.Configuration + .AddJsonFile($"appsettings-{appName}.json", optional: false, reloadOnChange: false); + + if (!String.IsNullOrWhiteSpace(builder.Environment.EnvironmentName)) + rootConfig.AddJsonFile($"appsettings-{appName}.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: false); + ; + rootConfig.AddEnvironmentVariables(); + } +} \ No newline at end of file diff --git a/src/Yavsc.Web/Program.cs b/src/Yavsc.Web/Program.cs index 8e189ba7..0024558a 100644 --- a/src/Yavsc.Web/Program.cs +++ b/src/Yavsc.Web/Program.cs @@ -12,14 +12,12 @@ using System.IdentityModel.Tokens.Jwt; using Microsoft.AspNetCore.Authentication; +using Yavsc.Server.Helpers; JwtSecurityTokenHandler.DefaultMapInboundClaims = true; var builder = WebApplication.CreateBuilder(args); -builder.Configuration - .AddJsonFile("appsettings-web.json", optional: false, reloadOnChange: false) - .AddJsonFile($"appsettings-blogs.{builder.Environment.EnvironmentName}.json", optional: false, reloadOnChange: false) - .AddEnvironmentVariables(); +builder.AddConfiguration("web"); var authSection = builder.Configuration.GetSection("Authentication"); var issuer = authSection.GetValue("Issuer"); diff --git a/src/Yavsc.Web/Yavsc.Web.csproj b/src/Yavsc.Web/Yavsc.Web.csproj index 51270671..0ffd7d38 100644 --- a/src/Yavsc.Web/Yavsc.Web.csproj +++ b/src/Yavsc.Web/Yavsc.Web.csproj @@ -6,6 +6,7 @@ + @@ -15,4 +16,4 @@ PreserveNewest - \ No newline at end of file +