2026-05-14 12:31:35 +02:00
|
|
|
using AuthorBuddy.Web.Components;
|
|
|
|
|
using AuthorBuddy.Web.Data;
|
|
|
|
|
using AuthorBuddy.Web.Models;
|
|
|
|
|
using AuthorBuddy.Web.Services;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
|
|
builder.Services.AddRazorComponents()
|
|
|
|
|
.AddInteractiveServerComponents();
|
|
|
|
|
|
|
|
|
|
builder.Services.AddSingleton<OllamaSettings>();
|
|
|
|
|
builder.Services.AddSingleton<IOllamaService, OllamaService>();
|
|
|
|
|
builder.Services.AddSingleton<IFileScannerService, FileScannerService>();
|
2026-05-16 16:13:35 +02:00
|
|
|
builder.Services.AddSingleton<ISettingsService, SettingsService>();
|
|
|
|
|
builder.Services.AddScoped<IThemeService, ThemeService>();
|
2026-05-14 12:31:35 +02:00
|
|
|
builder.Services.AddSingleton<IProjectService, ProjectService>();
|
|
|
|
|
|
|
|
|
|
builder.Services.AddDbContextFactory<AppDbContext>(options =>
|
|
|
|
|
options.UseSqlite(Constants.SQLiteConnection));
|
|
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
AppDbContext.InitializeDatabase(Constants.SQLiteConnection);
|
|
|
|
|
|
|
|
|
|
if (!app.Environment.IsDevelopment())
|
|
|
|
|
{
|
|
|
|
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
|
|
|
|
}
|
|
|
|
|
app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
|
|
|
|
|
app.UseAntiforgery();
|
|
|
|
|
|
|
|
|
|
app.MapStaticAssets();
|
|
|
|
|
app.MapRazorComponents<App>()
|
|
|
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
|
|
|
|
|
|
app.Run();
|