Compare commits
No commits in common. "993e66a0841c416cfcff22d05b5e98f4effc3aed" and "8e58c835267a5cf5292360e4c4353b3db33b17e4" have entirely different histories.
993e66a084
...
8e58c83526
@ -1,6 +1,5 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Mirea.Api.Endpoint.Configuration.General;
|
||||
using Mirea.Api.Endpoint.Configuration.General.Settings;
|
||||
|
||||
namespace Mirea.Api.Endpoint.Configuration.AppConfig;
|
||||
@ -9,7 +8,7 @@ public static class CacheConfiguration
|
||||
{
|
||||
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)
|
||||
{
|
||||
services.AddStackExchangeRedisCache(options =>
|
||||
|
@ -17,7 +17,7 @@ public static class LoggerConfiguration
|
||||
{
|
||||
hostBuilder.UseSerilog((context, _, configuration) =>
|
||||
{
|
||||
var generalConfig = context.Configuration.Get<GeneralConfig>()?.LogSettings;
|
||||
var generalConfig = context.Configuration.Get<GeneralConfig>();
|
||||
configuration
|
||||
.MinimumLevel.Debug()
|
||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
||||
@ -26,16 +26,16 @@ public static class LoggerConfiguration
|
||||
outputTemplate:
|
||||
"[{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)))
|
||||
Directory.CreateDirectory(generalConfig.LogFilePath);
|
||||
if (!string.IsNullOrEmpty(generalConfig.LogSettings.LogFilePath) && Directory.Exists(PathBuilder.Combine(generalConfig.LogSettings.LogFilePath)))
|
||||
Directory.CreateDirectory(generalConfig.LogSettings.LogFilePath);
|
||||
|
||||
configuration.WriteTo.File(
|
||||
new CompactJsonFormatter(),
|
||||
PathBuilder.Combine(
|
||||
generalConfig.LogFilePath!,
|
||||
generalConfig.LogFileName + ".json"
|
||||
generalConfig.LogSettings.LogFilePath!,
|
||||
generalConfig.LogSettings.LogFileName + ".json"
|
||||
),
|
||||
LogEventLevel.Debug,
|
||||
rollingInterval: RollingInterval.Day);
|
||||
|
@ -1,7 +1,6 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Mirea.Api.Endpoint.Common.Services.Security;
|
||||
using Mirea.Api.Endpoint.Configuration.General;
|
||||
using Mirea.Api.Endpoint.Configuration.General.Settings;
|
||||
using Mirea.Api.Security;
|
||||
using Mirea.Api.Security.Common.Interfaces;
|
||||
@ -17,7 +16,7 @@ public static class SecureConfiguration
|
||||
services.AddSingleton<IAccessToken, JwtTokenService>();
|
||||
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>();
|
||||
else
|
||||
services.AddSingleton<ICacheService, MemoryCacheService>();
|
||||
|
@ -2,7 +2,6 @@
|
||||
using Mirea.Api.Endpoint.Configuration.General.Attributes;
|
||||
using Mirea.Api.Endpoint.Configuration.General.Interfaces;
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Mirea.Api.Endpoint.Configuration.General.Settings;
|
||||
|
||||
@ -18,7 +17,6 @@ public class DbSettings : IIsConfigured
|
||||
public DatabaseEnum TypeDatabase { get; set; }
|
||||
public required string ConnectionStringSql { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public DatabaseProvider DatabaseProvider =>
|
||||
TypeDatabase switch
|
||||
{
|
||||
|
@ -9,6 +9,7 @@ using Mirea.Api.Endpoint.Common.Interfaces;
|
||||
using Mirea.Api.Endpoint.Common.Services;
|
||||
using Mirea.Api.Endpoint.Configuration.AppConfig;
|
||||
using Mirea.Api.Endpoint.Configuration.General;
|
||||
using Mirea.Api.Endpoint.Configuration.General.Settings;
|
||||
using Mirea.Api.Endpoint.Configuration.General.Validators;
|
||||
using Mirea.Api.Endpoint.Middleware;
|
||||
using System;
|
||||
@ -20,7 +21,7 @@ public class Program
|
||||
{
|
||||
public static IServiceCollection AddDatabase(IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
var dbSettings = configuration.Get<GeneralConfig>()?.DbSettings;
|
||||
var dbSettings = configuration.Get<DbSettings>();
|
||||
services.AddApplication();
|
||||
services.AddPersistence(
|
||||
dbSettings?.DatabaseProvider ?? DatabaseProvider.Sqlite,
|
||||
|
Loading…
Reference in New Issue
Block a user