SharpRSS/SharpRSS.Blazor/Program.cs

44 lines
1.2 KiB
C#
Raw Normal View History

using Blazored.LocalStorage;
using Microsoft.EntityFrameworkCore;
2024-06-17 13:53:48 +02:00
using MudBlazor.Services;
using SharpRSS.Blazor.Components;
using SharpRSS.Business;
using SharpRSS.Data;
var builder = WebApplication.CreateBuilder(args);
builder.UseSRSS();
builder.Services.AddBlazoredLocalStorage();
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
2024-06-17 13:53:48 +02:00
builder.Services.AddMudServices();
builder.Services.AddHttpContextAccessor(); // HttpContext accessor
var app = builder.Build();
var contextFactory = app.Services.GetService<IDbContextFactory<SRSSContext>>();
if (contextFactory != null)
{
await using var context = await contextFactory.CreateDbContextAsync();
context.Database.EnsureCreated();
}
// 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.UseStaticFiles();
app.UseAntiforgery();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
app.Run();