96 lines
3.4 KiB
C#
96 lines
3.4 KiB
C#
using BLAIzor.Components;
|
|
using BLAIzor.Data;
|
|
using BLAIzor.Helpers;
|
|
using BLAIzor.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Identity.UI.Services;
|
|
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Radzen;
|
|
using Sidio.Sitemap.AspNetCore;
|
|
using Sidio.Sitemap.Blazor;
|
|
using Sidio.Sitemap.Core.Services;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
var configuration = builder.Configuration;
|
|
builder.WebHost.UseWebRoot("wwwroot");
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddDbContext<ApplicationDbContext>(options =>
|
|
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
|
|
|
|
// Add Identity services
|
|
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
|
|
.AddEntityFrameworkStores<ApplicationDbContext>();
|
|
|
|
//builder.Services.AddBlazorServerOptions(options =>
|
|
//{
|
|
// options.MaxBufferSize = 50 * 1024 * 1024; // Set to 50 MB
|
|
//});
|
|
|
|
builder.Services.Configure<KestrelServerOptions>(options =>
|
|
{
|
|
options.Limits.MaxRequestBodySize = 50 * 1024 * 1024;
|
|
});
|
|
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddRazorComponents()
|
|
.AddInteractiveServerComponents();
|
|
|
|
builder.Services.AddRadzenComponents();
|
|
|
|
builder.Services.AddHttpClient();
|
|
builder.Services.AddScoped<AIService>();
|
|
builder.Services.AddSingleton<ContentService>();
|
|
builder.Services.AddScoped<ScopedContentService>();
|
|
builder.Services.AddScoped<QDrantService>();
|
|
builder.Services.AddScoped<OpenAIEmbeddingService>();
|
|
builder.Services.AddScoped<HtmlSnippetProcessor>();
|
|
builder.Services
|
|
.AddHttpContextAccessor()
|
|
.AddDefaultSitemapServices<HttpContextBaseUrlProvider>();
|
|
builder.Services.AddScoped<AuthenticationStateProvider, CustomAuthenticationStateProvider>();
|
|
builder.Services.AddScoped<CustomAuthenticationStateProvider>();
|
|
builder.Services.Configure<SmtpSettings>(builder.Configuration.GetSection("Smtp"));
|
|
builder.Services.AddTransient<IEmailSender, EmailService>();
|
|
builder.Services.AddScoped<ContentEditorService>();
|
|
builder.Services.AddScoped<CssTemplateService>();
|
|
builder.Services.AddScoped<DesignTemplateService>();
|
|
builder.Services.AddScoped<OpenAIApiService>();
|
|
builder.Services.AddScoped<DeepSeekApiService>();
|
|
builder.Services.AddScoped<OpenAiRealtimeService>();
|
|
builder.Services.AddScoped<CerebrasAPIService>();
|
|
builder.Services.AddScoped<CssInjectorService>();
|
|
builder.Services.AddHostedService<TempFileCleanupService>();
|
|
builder.Services.AddServerSideBlazor().AddCircuitOptions(options => options.DetailedErrors = true).AddHubOptions(options =>
|
|
{
|
|
options.MaximumReceiveMessageSize = 1024000; // e.g. 100 KB
|
|
}); ;
|
|
builder.Services.AddSignalR(hubOptions => {
|
|
hubOptions.MaximumReceiveMessageSize = 10 * 1024 * 1024; });
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseRouting();
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
app.UseStaticFiles();
|
|
app.UseAntiforgery();
|
|
app.MapRazorPages();
|
|
app.MapRazorComponents<App>()
|
|
.AddInteractiveServerRenderMode();
|
|
app.UseMiddleware<SubdomainMiddleware>();
|
|
app.UseSitemap();
|
|
app.Run();
|