From 41158b34c5fdf2f135a72ab185a4d52320909b40 Mon Sep 17 00:00:00 2001 From: cuqmbr Date: Thu, 29 May 2025 12:24:13 +0300 Subject: [PATCH] flatten configuration file structure --- src/Application/ConfigurationOptions.cs | 2 +- .../Configuration/Configuration.cs | 15 ++--- .../Infrastructure/Configuration.cs | 5 +- src/HttpApi/appsettings.Development.json | 58 +++++++++---------- src/HttpApi/appsettings.json | 58 +++++++++---------- src/Infrastructure/ConfigurationOptions.cs | 6 +- src/Persistence/ConfigurationOptions.cs | 2 +- 7 files changed, 69 insertions(+), 77 deletions(-) diff --git a/src/Application/ConfigurationOptions.cs b/src/Application/ConfigurationOptions.cs index 7a6edea..8944ec8 100644 --- a/src/Application/ConfigurationOptions.cs +++ b/src/Application/ConfigurationOptions.cs @@ -2,7 +2,7 @@ namespace cuqmbr.TravelGuide.Application; public sealed class ConfigurationOptions { - public static string SectionName { get; } = "Application"; + public static string SectionName { get; } = ""; public LocalizationConfigurationOptions Localization { get; set; } = new(); diff --git a/src/Configuration/Configuration/Configuration.cs b/src/Configuration/Configuration/Configuration.cs index 923b7f8..d4b2ecc 100644 --- a/src/Configuration/Configuration/Configuration.cs +++ b/src/Configuration/Configuration/Configuration.cs @@ -25,17 +25,14 @@ public static class Configuration .AddCommandLine(args) .Build(); - services.AddOptions().Bind( - configuration.GetSection( - PersistenceConfigurationOptions.SectionName)); + services.AddOptions() + .Bind(configuration); - services.AddOptions().Bind( - configuration.GetSection( - ApplicationConfigurationOptions.SectionName)); + services.AddOptions() + .Bind(configuration); - services.AddOptions().Bind( - configuration.GetSection( - InfrastructureConfigurationOptions.SectionName)); + services.AddOptions() + .Bind(configuration); return services; } diff --git a/src/Configuration/Infrastructure/Configuration.cs b/src/Configuration/Infrastructure/Configuration.cs index 1c35fe6..3dd3f4b 100644 --- a/src/Configuration/Infrastructure/Configuration.cs +++ b/src/Configuration/Infrastructure/Configuration.cs @@ -21,7 +21,10 @@ public static class Configuration ExchangeApiCurrencyConverterService>() .AddScoped< cuqmbr.TravelGuide.Application.Common.Services.LiqPayPaymentService, - cuqmbr.TravelGuide.Infrastructure.Services.LiqPayPaymentService>(); + cuqmbr.TravelGuide.Infrastructure.Services.LiqPayPaymentService>() + .AddScoped< + EmailSenderService, + MailKitEmailSenderService>(); return services; } diff --git a/src/HttpApi/appsettings.Development.json b/src/HttpApi/appsettings.Development.json index 81ff06d..05be9dc 100644 --- a/src/HttpApi/appsettings.Development.json +++ b/src/HttpApi/appsettings.Development.json @@ -1,35 +1,31 @@ { - "Application": { - "Logging": { - "Type": "SimpleConsole", - "LogLevel": "Information", - "TimestampFormat": "yyyy-MM-ddTHH:mm:ss.fffK", - "UseUtcTimestamp": true - }, - "Datastore": { - "Type": "postgresql", - "ConnectionString": "Host=127.0.0.1:5432;Database=travel_guide;Username=postgres;Password=0000;Include Error Detail=true" - }, - "Localization": { - "DefaultCultureName": "en-US", - "CacheDuration": "00:30:00" - }, - "JsonWebToken": { - "Issuer": "https://api.travel-guide.cuqmbr.xyz", - "Audience": "https://travel-guide.cuqmbr.xyz", - "IssuerSigningKey": "a2c98dec80787a4e85ffb5bcbc24f7e4cc014d8a4fe43e9520480a50759164bc", - "AccessTokenValidity": "24:00:00", - "RefreshTokenValidity": "72:00:00" - }, - "Infrastructure": { - "PaymentProcessing": { - "CallbackAddressBase": "https://api.travel-guide.cuqmbr.xyz", - "ResultAddressBase": "https://travel-guide.cuqmbr.xyz", - "LiqPay": { - "PublicKey": "sandbox_xxxxxxxxxxxx", - "PrivateKey": "sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" - } - } + "Logging": { + "Type": "SimpleConsole", + "LogLevel": "Information", + "TimestampFormat": "yyyy-MM-ddTHH:mm:ss.fffK", + "UseUtcTimestamp": true + }, + "Localization": { + "DefaultCultureName": "en-US", + "CacheDuration": "00:30:00" + }, + "JsonWebToken": { + "Issuer": "https://api.travel-guide.cuqmbr.xyz", + "Audience": "https://travel-guide.cuqmbr.xyz", + "IssuerSigningKey": "a2c98dec80787a4e85ffb5bcbc24f7e4cc014d8a4fe43e9520480a50759164bc", + "AccessTokenValidity": "24:00:00", + "RefreshTokenValidity": "72:00:00" + }, + "Datastore": { + "Type": "postgresql", + "ConnectionString": "Host=127.0.0.1:5432;Database=travel_guide;Username=postgres;Password=0000;Include Error Detail=true" + }, + "PaymentProcessing": { + "CallbackAddressBase": "https://api.travel-guide.cuqmbr.xyz", + "ResultAddressBase": "https://travel-guide.cuqmbr.xyz", + "LiqPay": { + "PublicKey": "sandbox_xxxxxxxxxxxx", + "PrivateKey": "sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } } } diff --git a/src/HttpApi/appsettings.json b/src/HttpApi/appsettings.json index 81ff06d..05be9dc 100644 --- a/src/HttpApi/appsettings.json +++ b/src/HttpApi/appsettings.json @@ -1,35 +1,31 @@ { - "Application": { - "Logging": { - "Type": "SimpleConsole", - "LogLevel": "Information", - "TimestampFormat": "yyyy-MM-ddTHH:mm:ss.fffK", - "UseUtcTimestamp": true - }, - "Datastore": { - "Type": "postgresql", - "ConnectionString": "Host=127.0.0.1:5432;Database=travel_guide;Username=postgres;Password=0000;Include Error Detail=true" - }, - "Localization": { - "DefaultCultureName": "en-US", - "CacheDuration": "00:30:00" - }, - "JsonWebToken": { - "Issuer": "https://api.travel-guide.cuqmbr.xyz", - "Audience": "https://travel-guide.cuqmbr.xyz", - "IssuerSigningKey": "a2c98dec80787a4e85ffb5bcbc24f7e4cc014d8a4fe43e9520480a50759164bc", - "AccessTokenValidity": "24:00:00", - "RefreshTokenValidity": "72:00:00" - }, - "Infrastructure": { - "PaymentProcessing": { - "CallbackAddressBase": "https://api.travel-guide.cuqmbr.xyz", - "ResultAddressBase": "https://travel-guide.cuqmbr.xyz", - "LiqPay": { - "PublicKey": "sandbox_xxxxxxxxxxxx", - "PrivateKey": "sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" - } - } + "Logging": { + "Type": "SimpleConsole", + "LogLevel": "Information", + "TimestampFormat": "yyyy-MM-ddTHH:mm:ss.fffK", + "UseUtcTimestamp": true + }, + "Localization": { + "DefaultCultureName": "en-US", + "CacheDuration": "00:30:00" + }, + "JsonWebToken": { + "Issuer": "https://api.travel-guide.cuqmbr.xyz", + "Audience": "https://travel-guide.cuqmbr.xyz", + "IssuerSigningKey": "a2c98dec80787a4e85ffb5bcbc24f7e4cc014d8a4fe43e9520480a50759164bc", + "AccessTokenValidity": "24:00:00", + "RefreshTokenValidity": "72:00:00" + }, + "Datastore": { + "Type": "postgresql", + "ConnectionString": "Host=127.0.0.1:5432;Database=travel_guide;Username=postgres;Password=0000;Include Error Detail=true" + }, + "PaymentProcessing": { + "CallbackAddressBase": "https://api.travel-guide.cuqmbr.xyz", + "ResultAddressBase": "https://travel-guide.cuqmbr.xyz", + "LiqPay": { + "PublicKey": "sandbox_xxxxxxxxxxxx", + "PrivateKey": "sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } } } diff --git a/src/Infrastructure/ConfigurationOptions.cs b/src/Infrastructure/ConfigurationOptions.cs index 338297e..b0642ee 100644 --- a/src/Infrastructure/ConfigurationOptions.cs +++ b/src/Infrastructure/ConfigurationOptions.cs @@ -2,9 +2,9 @@ namespace cuqmbr.TravelGuide.Infrastructure; public sealed class ConfigurationOptions { - public static string SectionName { get; } = "Application:Infrastructure"; + public static string SectionName { get; } = ""; - public PaymentProcessingConfigurationOptions PaymentProcessing { get; set; } + public PaymentProcessingConfigurationOptions PaymentProcessing { get; set; } = new(); } public sealed class PaymentProcessingConfigurationOptions @@ -13,7 +13,7 @@ public sealed class PaymentProcessingConfigurationOptions public string ResultAddressBase { get; set; } - public LiqPayConfigurationOptions LiqPay { get; set; } + public LiqPayConfigurationOptions LiqPay { get; set; } = new(); } public sealed class LiqPayConfigurationOptions diff --git a/src/Persistence/ConfigurationOptions.cs b/src/Persistence/ConfigurationOptions.cs index 67f5dd5..a239384 100644 --- a/src/Persistence/ConfigurationOptions.cs +++ b/src/Persistence/ConfigurationOptions.cs @@ -2,7 +2,7 @@ namespace cuqmbr.TravelGuide.Persistence; public sealed class ConfigurationOptions { - public static string SectionName { get; } = "Application:Datastore"; + public static string SectionName { get; } = "Datastore"; public string Type { get; set; } = "inmemory";