Added hopframe backend

This commit is contained in:
2025-11-30 19:01:38 +01:00
parent 825bd80ef0
commit 5d1fc1f347
19 changed files with 523 additions and 17 deletions

View File

@@ -1,6 +1,9 @@
using HopFrame.Core.Services;
using HopFrame.Web;
using Microsoft.EntityFrameworkCore;
using SpotiParty.Web;
using SpotiParty.Web.Components;
using SpotiParty.Web.Models;
using SpotiParty.Web.Services;
var builder = WebApplication.CreateBuilder(args);
@@ -11,9 +14,44 @@ builder.Services.AddRazorComponents()
builder.AddServiceDefaults();
builder.Services.AddHttpContextAccessor();
builder.Services.AddScoped<ClientSideStorage>();
builder.AddNpgsqlDbContext<DatabaseContext>("SpotiParty");
builder.Services.AddDbContextFactory<DatabaseContext>(options => {
options.UseNpgsql(builder.Configuration.GetConnectionString("SpotiParty"));
});
builder.Services.AddScoped<AuthorizationHandler>();
builder.Services.AddScoped<IHopFrameAuthHandler, DashboardAuthHandler>();
builder.Services.AddHopFrame(config => {
config.SetLoginPage("/login");
config.AddDbContext<DatabaseContext>(context => {
context.Table<User>(table => {
table
.SetViewPolicy(DashboardAuthHandler.AdminPolicy)
.SetCreatePolicy(DashboardAuthHandler.AdminPolicy)
.SetUpdatePolicy(DashboardAuthHandler.AdminPolicy)
.SetDeletePolicy(DashboardAuthHandler.AdminPolicy);
table.Property(u => u.RefreshToken)
.List(false)
.DisplayValue(false)
.SetEditable(false);
table.ShowSearchSuggestions(false);
});
context.Table<Event>(table => {
table.Property(e => e.Id)
.List(false)
.SetEditable(false);
table.ShowSearchSuggestions(false);
});
});
});
var app = builder.Build();
// Configure the HTTP request pipeline.
@@ -37,6 +75,7 @@ app.UseAntiforgery();
app.MapStaticAssets();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
.AddInteractiveServerRenderMode()
.AddHopFramePages();
app.Run();