Compare commits

..

No commits in common. "993e66a0841c416cfcff22d05b5e98f4effc3aed" and "8e58c835267a5cf5292360e4c4353b3db33b17e4" have entirely different histories.

5 changed files with 10 additions and 13 deletions

View File

@ -1,6 +1,5 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Mirea.Api.Endpoint.Configuration.General;
using Mirea.Api.Endpoint.Configuration.General.Settings; using Mirea.Api.Endpoint.Configuration.General.Settings;
namespace Mirea.Api.Endpoint.Configuration.AppConfig; namespace Mirea.Api.Endpoint.Configuration.AppConfig;
@ -9,7 +8,7 @@ public static class CacheConfiguration
{ {
public static IServiceCollection AddCustomRedis(this IServiceCollection services, IConfiguration configuration) public static IServiceCollection AddCustomRedis(this IServiceCollection services, IConfiguration configuration)
{ {
var cache = configuration.Get<GeneralConfig>()?.CacheSettings; var cache = configuration.Get<CacheSettings>();
if (cache?.TypeDatabase == CacheSettings.CacheEnum.Redis) if (cache?.TypeDatabase == CacheSettings.CacheEnum.Redis)
{ {
services.AddStackExchangeRedisCache(options => services.AddStackExchangeRedisCache(options =>

View File

@ -17,7 +17,7 @@ public static class LoggerConfiguration
{ {
hostBuilder.UseSerilog((context, _, configuration) => hostBuilder.UseSerilog((context, _, configuration) =>
{ {
var generalConfig = context.Configuration.Get<GeneralConfig>()?.LogSettings; var generalConfig = context.Configuration.Get<GeneralConfig>();
configuration configuration
.MinimumLevel.Debug() .MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
@ -26,16 +26,16 @@ public static class LoggerConfiguration
outputTemplate: outputTemplate:
"[{Level:u3}] [{Timestamp:dd.MM.yyyy HH:mm:ss}] {Message:lj}{NewLine}{Exception}"); "[{Level:u3}] [{Timestamp:dd.MM.yyyy HH:mm:ss}] {Message:lj}{NewLine}{Exception}");
if (generalConfig?.EnableLogToFile == true) if (generalConfig?.LogSettings?.EnableLogToFile == true)
{ {
if (!string.IsNullOrEmpty(generalConfig.LogFilePath) && Directory.Exists(PathBuilder.Combine(generalConfig.LogFilePath))) if (!string.IsNullOrEmpty(generalConfig.LogSettings.LogFilePath) && Directory.Exists(PathBuilder.Combine(generalConfig.LogSettings.LogFilePath)))
Directory.CreateDirectory(generalConfig.LogFilePath); Directory.CreateDirectory(generalConfig.LogSettings.LogFilePath);
configuration.WriteTo.File( configuration.WriteTo.File(
new CompactJsonFormatter(), new CompactJsonFormatter(),
PathBuilder.Combine( PathBuilder.Combine(
generalConfig.LogFilePath!, generalConfig.LogSettings.LogFilePath!,
generalConfig.LogFileName + ".json" generalConfig.LogSettings.LogFileName + ".json"
), ),
LogEventLevel.Debug, LogEventLevel.Debug,
rollingInterval: RollingInterval.Day); rollingInterval: RollingInterval.Day);

View File

@ -1,7 +1,6 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Mirea.Api.Endpoint.Common.Services.Security; using Mirea.Api.Endpoint.Common.Services.Security;
using Mirea.Api.Endpoint.Configuration.General;
using Mirea.Api.Endpoint.Configuration.General.Settings; using Mirea.Api.Endpoint.Configuration.General.Settings;
using Mirea.Api.Security; using Mirea.Api.Security;
using Mirea.Api.Security.Common.Interfaces; using Mirea.Api.Security.Common.Interfaces;
@ -17,7 +16,7 @@ public static class SecureConfiguration
services.AddSingleton<IAccessToken, JwtTokenService>(); services.AddSingleton<IAccessToken, JwtTokenService>();
services.AddSingleton<IRevokedToken, MemoryRevokedTokenService>(); services.AddSingleton<IRevokedToken, MemoryRevokedTokenService>();
if (configuration.Get<GeneralConfig>()?.CacheSettings?.TypeDatabase == CacheSettings.CacheEnum.Redis) if (configuration.Get<CacheSettings>()?.TypeDatabase == CacheSettings.CacheEnum.Redis)
services.AddSingleton<ICacheService, DistributedCacheService>(); services.AddSingleton<ICacheService, DistributedCacheService>();
else else
services.AddSingleton<ICacheService, MemoryCacheService>(); services.AddSingleton<ICacheService, MemoryCacheService>();

View File

@ -2,7 +2,6 @@
using Mirea.Api.Endpoint.Configuration.General.Attributes; using Mirea.Api.Endpoint.Configuration.General.Attributes;
using Mirea.Api.Endpoint.Configuration.General.Interfaces; using Mirea.Api.Endpoint.Configuration.General.Interfaces;
using System; using System;
using System.Text.Json.Serialization;
namespace Mirea.Api.Endpoint.Configuration.General.Settings; namespace Mirea.Api.Endpoint.Configuration.General.Settings;
@ -18,7 +17,6 @@ public class DbSettings : IIsConfigured
public DatabaseEnum TypeDatabase { get; set; } public DatabaseEnum TypeDatabase { get; set; }
public required string ConnectionStringSql { get; set; } public required string ConnectionStringSql { get; set; }
[JsonIgnore]
public DatabaseProvider DatabaseProvider => public DatabaseProvider DatabaseProvider =>
TypeDatabase switch TypeDatabase switch
{ {

View File

@ -9,6 +9,7 @@ using Mirea.Api.Endpoint.Common.Interfaces;
using Mirea.Api.Endpoint.Common.Services; using Mirea.Api.Endpoint.Common.Services;
using Mirea.Api.Endpoint.Configuration.AppConfig; using Mirea.Api.Endpoint.Configuration.AppConfig;
using Mirea.Api.Endpoint.Configuration.General; using Mirea.Api.Endpoint.Configuration.General;
using Mirea.Api.Endpoint.Configuration.General.Settings;
using Mirea.Api.Endpoint.Configuration.General.Validators; using Mirea.Api.Endpoint.Configuration.General.Validators;
using Mirea.Api.Endpoint.Middleware; using Mirea.Api.Endpoint.Middleware;
using System; using System;
@ -20,7 +21,7 @@ public class Program
{ {
public static IServiceCollection AddDatabase(IServiceCollection services, IConfiguration configuration) public static IServiceCollection AddDatabase(IServiceCollection services, IConfiguration configuration)
{ {
var dbSettings = configuration.Get<GeneralConfig>()?.DbSettings; var dbSettings = configuration.Get<DbSettings>();
services.AddApplication(); services.AddApplication();
services.AddPersistence( services.AddPersistence(
dbSettings?.DatabaseProvider ?? DatabaseProvider.Sqlite, dbSettings?.DatabaseProvider ?? DatabaseProvider.Sqlite,