42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using SpotiParty.Web;
|
|
using SpotiParty.Web.Components;
|
|
using SpotiParty.Web.Services;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddRazorComponents()
|
|
.AddInteractiveServerComponents();
|
|
|
|
builder.AddServiceDefaults();
|
|
|
|
builder.AddNpgsqlDbContext<DatabaseContext>("SpotiParty");
|
|
builder.Services.AddScoped<AuthorizationHandler>();
|
|
|
|
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();
|
|
}
|
|
|
|
await using (var scope = app.Services.CreateAsyncScope()) {
|
|
var context = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
|
|
await context.Database.MigrateAsync();
|
|
}
|
|
|
|
app.MapDefaultEndpoints();
|
|
|
|
app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
|
|
//app.UseHttpsRedirection();
|
|
|
|
app.UseAntiforgery();
|
|
|
|
app.MapStaticAssets();
|
|
app.MapRazorComponents<App>()
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
app.Run(); |