mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 22:11:10 +00:00
Adds media items location options
This commit is contained in:
1 parent
cc9ee52040
commit
f5dbeccb0a
11 files changed
+94
-27
No files matched your search
@@ -42,6 +42,13 @@ public static class SharedConfiguration
|
||||
.Bind(configuration.GetRequiredSection(DatabaseSettingsModel.SECTION_NAME))
|
||||
.ValidateFluently()
|
||||
.ValidateOnStart();
|
||||
|
||||
|
||||
services.AddOptions<MediaSettingsModel>()
|
||||
.Bind(configuration.GetRequiredSection(MediaSettingsModel.SECTION_NAME))
|
||||
.ValidateFluently()
|
||||
.ValidateOnStart();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,5 +13,6 @@ public static partial class Errors
|
||||
{
|
||||
public static Error ApplicationThemeCannotBeEmpty => Error.Validation(description: nameof(ApplicationThemeCannotBeEmpty));
|
||||
public static Error DatabaseConnectionStringCannotBeEmpty => Error.Validation(description: nameof(DatabaseConnectionStringCannotBeEmpty));
|
||||
public static Error MediaRootDirectoryCannotBeEmpty => Error.Validation(description: nameof(MediaRootDirectoryCannotBeEmpty));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Common.Models.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Model for deserializing media settings.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{SECTION_NAME}")]
|
||||
public class MediaSettingsModel
|
||||
{
|
||||
public const string SECTION_NAME = "MediaSettings";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the root directory where media files are stored.
|
||||
/// </summary>
|
||||
public required string RootDirectory { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FluentValidation;
|
||||
using Lumina.Infrastructure.Common.Models.Configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Common.Validators;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for the MediaSettings application configuration settings section.
|
||||
/// </summary>
|
||||
public class MediaSettingsModelValidator : AbstractValidator<MediaSettingsModel>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MediaSettingsModelValidator"/> class.
|
||||
/// </summary>
|
||||
public MediaSettingsModelValidator()
|
||||
{
|
||||
RuleFor(x => x.RootDirectory).NotEmpty().WithMessage(Errors.Errors.Configuration.MediaRootDirectoryCannotBeEmpty.Description);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@
|
||||
<None Update="appsettings.shared.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="appsettings.shared.Development.json">
|
||||
<None Update="appsettings.shared.development.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<DependentUpon>appsettings.shared.json</DependentUpon>
|
||||
</None>
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
{
|
||||
"MediaSettings": {
|
||||
"RootDirectory": "wwwroot/media"
|
||||
},
|
||||
"CommonSettings": {
|
||||
"Theme": "LuminaDark"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=localhost;Database=Lumina;User Id=sa;Password=Password123;"
|
||||
"DefaultConnection": "Server=<host>;Database=<database>;User Id=<user>;Password=<password>;"
|
||||
},
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
@@ -18,4 +21,4 @@
|
||||
"WithThreadId"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user