75 lines
2.5 KiB
C#
75 lines
2.5 KiB
C#
using Blazorise;
|
|
using Blazorise.Icons.Material;
|
|
using Blazorise.LoadingIndicator;
|
|
using Blazorise.Material;
|
|
using Gremlin_BlazorServer.Areas.Identity;
|
|
using Gremlin_BlazorServer.Data;
|
|
using Gremlin_BlazorServer.Data.DBClasses;
|
|
using Gremlin_BlazorServer.Services;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using GenericImporter = Gremlin_BlazorServer.Services.GenericImporter;
|
|
//using Blazorise.Bootstrap;
|
|
//using Blazorise.Icons.FontAwesome;
|
|
|
|
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddRazorPages();
|
|
builder.Services.AddServerSideBlazor();
|
|
|
|
builder.Services.AddScoped<GremlinDb>();
|
|
builder.Services.AddScoped<GenericController>();
|
|
builder.Services.AddScoped<HostingService>();
|
|
builder.Services.AddScoped<QuoteHandling>();
|
|
builder.Services.AddScoped<GenericImporter>();
|
|
|
|
builder.Services.AddBlazorise(options => { options.Immediate = true; })
|
|
//.AddBootstrapProviders()
|
|
//.AddBootstrapComponents()
|
|
//.AddFontAwesomeIcons()
|
|
.AddMaterialProviders().AddMaterialIcons();
|
|
builder.Services.AddOptions();
|
|
builder.Services.AddLoadingIndicator();
|
|
|
|
//Auth
|
|
const string connection = "server0";
|
|
string connectionString = builder.Configuration.GetConnectionString(connection) ?? throw new InvalidOperationException($"Connection string '{connection}' not found.");
|
|
ServerVersion serverVersion = ServerVersion.AutoDetect(connectionString);
|
|
builder.Services.AddDbContext<BlazorAuthDb>(options => options.UseMySql(connectionString, serverVersion));
|
|
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true).AddEntityFrameworkStores<BlazorAuthDb>();
|
|
builder.Services.AddScoped<AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider<IdentityUser>>();
|
|
builder.Services.AddControllersWithViews();
|
|
|
|
//
|
|
|
|
builder.WebHost.UseWebRoot("wwwroot");
|
|
builder.WebHost.UseStaticWebAssets();
|
|
|
|
builder.WebHost.UseUrls("https://*:5000");
|
|
|
|
WebApplication app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (!app.Environment.IsDevelopment()) {
|
|
_ = app.UseExceptionHandler("/Error");
|
|
// 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.UseRouting();
|
|
|
|
//Auth
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.MapBlazorHub();
|
|
app.MapFallbackToPage("/_Host");
|
|
|
|
app.Run(); |