Added hopframe backend
This commit is contained in:
@@ -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();
|
||||
Reference in New Issue
Block a user