All checks were successful
Build and deploy / Publish image (push) Successful in 1m6s
71 lines
2.4 KiB
C#
71 lines
2.4 KiB
C#
using Gotenberg.Sharp.API.Client;
|
|
using Gotenberg.Sharp.API.Client.Domain.Settings;
|
|
using Gotenberg.Sharp.API.Client.Extensions;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.HttpOverrides;
|
|
using Microsoft.AspNetCore.Mvc.Authorization;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Identity.Web;
|
|
using Microsoft.Identity.Web.UI;
|
|
using Otchinslator;
|
|
using Otchinslator.Components;
|
|
using Otchinslator.Services;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services.AddMicrosoftIdentityWebAppAuthentication(builder.Configuration);
|
|
builder.Services.AddHttpContextAccessor();
|
|
builder.Services.AddControllersWithViews(options =>
|
|
{
|
|
var policy = new AuthorizationPolicyBuilder()
|
|
.RequireAuthenticatedUser()
|
|
.Build();
|
|
options.Filters.Add(new AuthorizeFilter(policy));
|
|
}).AddMicrosoftIdentityUI().AddDataAnnotationsLocalization();
|
|
builder.Services.Configure<ForwardedHeadersOptions>(options =>
|
|
{
|
|
options.KnownNetworks.Clear();
|
|
options.KnownProxies.Clear();
|
|
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
|
});
|
|
|
|
var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
|
var folder = Path.Join(baseDirectory, "Data");
|
|
if (!Directory.Exists(folder))
|
|
Directory.CreateDirectory(folder);
|
|
|
|
folder = Path.Join(folder, "database.db");
|
|
builder.Services.AddDbContext<DatabaseContext>(options => options.UseSqlite($"Data Source={folder}"));
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddRazorComponents()
|
|
.AddInteractiveServerComponents();
|
|
builder.Services.AddJSComponents();
|
|
|
|
builder.Services.AddRazorPages(); //////////////
|
|
builder.Services.AddServerSideBlazor(); //////////////
|
|
|
|
builder.Services.AddOptions<GotenbergSharpClientOptions>()
|
|
.Bind(builder.Configuration.GetSection(nameof(GotenbergSharpClient)));
|
|
builder.Services.AddGotenbergSharpClient();
|
|
builder.Services.AddScoped<IStatementGenerator, StatementGenerator>();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
|
}
|
|
|
|
app.UseStaticFiles();
|
|
app.UseAntiforgery();
|
|
app.MapControllers();
|
|
app.UseAuthorization();
|
|
app.UseForwardedHeaders();
|
|
|
|
app.MapRazorComponents<App>();
|
|
// .AddInteractiveServerRenderMode();
|
|
|
|
app.Run();
|