init
This commit is contained in:
@@ -6,27 +6,35 @@ using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using MudBlazor.Services;
|
||||
using MyAppName.WebApp.Components.Account;
|
||||
using OpenArchival.Blazor;
|
||||
using OpenArchival.Blazor.AdminPages;
|
||||
using OpenArchival.Blazor.AdminPages.Shared;
|
||||
using OpenArchival.Blazor.ArchiveDisplay;
|
||||
using OpenArchival.Blazor.Components;
|
||||
using OpenArchival.Blazor.Config;
|
||||
using OpenArchival.Blazor.CustomComponents;
|
||||
using OpenArchival.DataAccess;
|
||||
using OpenArchival.DataAccess.FileAccessManager;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var uploadSettings = builder.Configuration.GetSection(FileUploadOptions.Key).Get<FileUploadOptions>() ?? throw new ArgumentNullException("FileUploadOptions");
|
||||
|
||||
// --- UI Services ---
|
||||
builder.Services.AddRazorComponents()
|
||||
.AddInteractiveServerComponents();
|
||||
.AddInteractiveServerComponents()
|
||||
.AddHubOptions(options =>
|
||||
{
|
||||
options.MaximumReceiveMessageSize = 1000 * 1024 * 1024;
|
||||
options.ClientTimeoutInterval = TimeSpan.FromSeconds(60);
|
||||
options.HandshakeTimeout = TimeSpan.FromSeconds(30);
|
||||
});
|
||||
|
||||
builder.Services.AddMudServices();
|
||||
builder.Services.AddMudExtensions();
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddHttpClient();
|
||||
|
||||
// --- Database & Identity Configuration ---
|
||||
// Get the single connection string for your PostgreSQL database.
|
||||
@@ -59,20 +67,12 @@ builder.Services.AddAuthentication(options =>
|
||||
})
|
||||
.AddIdentityCookies();
|
||||
|
||||
// --- File Upload Configuration ---
|
||||
// File Upload Configuration
|
||||
builder.Services.AddOptions<FileUploadOptions>().Bind(builder.Configuration.GetSection(FileUploadOptions.Key));
|
||||
builder.Services.AddOptions<ApplicationOptions>().Bind(builder.Configuration.GetSection(ApplicationOptions.Key));
|
||||
|
||||
var uploadSettings = builder.Configuration.GetSection(FileUploadOptions.Key).Get<FileUploadOptions>() ?? throw new ArgumentNullException("FileUploadOptions");
|
||||
builder.Services.AddServerSideBlazor().AddHubOptions(options =>
|
||||
{
|
||||
options.MaximumReceiveMessageSize = uploadSettings.MaxUploadSizeBytes;
|
||||
options.MaximumReceiveMessageSize = 1024 * 1024 * 10; // 10MB
|
||||
options.ClientTimeoutInterval = TimeSpan.FromSeconds(60);
|
||||
options.HandshakeTimeout = TimeSpan.FromSeconds(30);
|
||||
});
|
||||
|
||||
// --- Custom Application Services ---
|
||||
// Custom Application Services
|
||||
builder.Services.AddScoped<IArchiveCategoryProvider, ArchiveCategoryProvider>();
|
||||
builder.Services.AddScoped<IFilePathListingProvider, FilePathListingProvider>();
|
||||
builder.Services.AddScoped<IArtifactStorageLocationProvider, ArtifactStorageLocationProvider>();
|
||||
@@ -84,6 +84,8 @@ builder.Services.AddScoped<ArtifactEntrySharedHelpers>();
|
||||
builder.Services.AddScoped<IArtifactGroupingProvider, ArtifactGroupingProvider>();
|
||||
builder.Services.AddScoped<ArtifactGroupingSearch>();
|
||||
builder.Services.AddScoped<BlogPostSearch>();
|
||||
builder.Services.AddScoped<IFileAccessManager, FileAccessManager>();
|
||||
builder.Services.AddScoped<IImageThumbnailer, ImageThumbnailer>();
|
||||
|
||||
builder.Services.AddLogging();
|
||||
|
||||
@@ -91,6 +93,8 @@ builder.Services.AddDataProtection()
|
||||
.PersistKeysToFileSystem(new DirectoryInfo("/app/keys"))
|
||||
.SetApplicationName("OpenArchival");
|
||||
|
||||
builder.Services.AddMemoryCache();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.MapControllers();
|
||||
@@ -118,7 +122,7 @@ using (var scope = app.Services.CreateScope())
|
||||
System.Environment.Exit(1);
|
||||
}
|
||||
|
||||
// Add the admin user
|
||||
// Add the admin user
|
||||
try
|
||||
{
|
||||
await IdentityDataSeeder.SeedRolesAndAdminUserAsync(serviceProvider);
|
||||
@@ -127,8 +131,12 @@ using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
logger.LogError(ex, "An error occurred while seeding the database with admin credentials.");
|
||||
}
|
||||
|
||||
// Seed the home page configuration
|
||||
await HomepageConfigurationSeeder.SeedHomepageConfig(serviceProvider);
|
||||
}
|
||||
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
@@ -153,7 +161,7 @@ app.MapRazorComponents<App>()
|
||||
|
||||
app.MapAdditionalIdentityEndpoints();
|
||||
|
||||
app.MapPost("/Logout", async (Microsoft.AspNetCore.Identity.SignInManager<OpenArchival.DataAccess.ApplicationUser> signInManager) =>
|
||||
app.MapPost("/Logout", async (SignInManager<OpenArchival.DataAccess.ApplicationUser> signInManager) =>
|
||||
{
|
||||
await signInManager.SignOutAsync();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user