46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using System.Reflection;
|
|
using Authinator.Backend.Database;
|
|
using Authinator.Backend.Utils;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Swashbuckle.AspNetCore.Filters;
|
|
|
|
var db = new DatabaseContext();
|
|
db.Database.Migrate();
|
|
db.Initialize();
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
if (Environment.GetCommandLineArgs().Contains("--razor-runtime-comp")) {
|
|
builder.Services.AddRazorPages().AddRazorRuntimeCompilation();
|
|
builder.Services.AddControllers().AddRazorRuntimeCompilation();
|
|
}
|
|
else {
|
|
builder.Services.AddRazorPages();
|
|
builder.Services.AddControllers();
|
|
}
|
|
|
|
builder.Services.AddSwaggerGen(options => {
|
|
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
|
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
|
|
options.ExampleFilters();
|
|
});
|
|
builder.Services.AddSwaggerExamplesFromAssemblies(Assembly.GetEntryAssembly());
|
|
|
|
var app = builder.Build();
|
|
|
|
if (!app.Environment.IsDevelopment())
|
|
app.UseExceptionHandler("/Error");
|
|
|
|
app.UseStatusCodePagesWithReExecute("/Error");
|
|
|
|
app.UseStaticFiles();
|
|
|
|
app.UseRouting();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapRazorPages();
|
|
app.MapControllers();
|
|
|
|
app.Run();
|