2024-08-04 18:44:33 -05:00
|
|
|
using LANCommander.Server.Services;
|
2024-08-28 20:33:59 -05:00
|
|
|
using Serilog;
|
2025-02-08 15:28:13 -06:00
|
|
|
using LANCommander.Server.Services.Models;
|
|
|
|
|
using LANCommander.Server.UI;
|
2025-03-11 19:32:38 -05:00
|
|
|
using LANCommander.Server.Startup;
|
2025-02-08 14:07:29 -06:00
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
2025-02-08 15:28:13 -06:00
|
|
|
if (args.Contains("--debugger"))
|
2025-03-11 21:21:16 -05:00
|
|
|
builder.WaitForDebugger();
|
2025-02-08 15:28:13 -06:00
|
|
|
|
2025-03-07 20:44:32 -06:00
|
|
|
if (args.Contains("--docker"))
|
|
|
|
|
SettingService.WorkingDirectory = "/app/config";
|
|
|
|
|
|
2025-02-08 15:28:13 -06:00
|
|
|
builder.AddAsService();
|
2025-02-08 14:07:29 -06:00
|
|
|
builder.AddLogger();
|
|
|
|
|
|
2025-03-07 23:12:07 -06:00
|
|
|
Settings settings;
|
|
|
|
|
|
2025-03-11 21:21:16 -05:00
|
|
|
builder.AddSettings(out settings);
|
2025-03-05 00:32:32 -06:00
|
|
|
|
2025-03-11 21:21:16 -05:00
|
|
|
builder.AddRazor();
|
2025-02-08 14:07:29 -06:00
|
|
|
builder.AddSignalR();
|
|
|
|
|
builder.AddCors();
|
|
|
|
|
builder.AddControllers();
|
2025-02-08 15:28:13 -06:00
|
|
|
builder.ConfigureKestrel();
|
2025-03-11 21:21:16 -05:00
|
|
|
builder.ConfigureAuthentication(settings);
|
2025-02-08 14:07:29 -06:00
|
|
|
builder.AddIdentity(settings);
|
|
|
|
|
builder.AddHangfire();
|
2025-02-09 01:23:33 -06:00
|
|
|
builder.AddOpenApi();
|
2025-02-08 14:07:29 -06:00
|
|
|
builder.AddLANCommanderServices(settings);
|
|
|
|
|
builder.AddDatabase();
|
|
|
|
|
|
|
|
|
|
Log.Debug("Building Application");
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
2025-03-11 21:21:16 -05:00
|
|
|
app.UseDatabase(args);
|
|
|
|
|
|
2025-02-08 14:07:29 -06:00
|
|
|
app.UseCors("CorsPolicy");
|
2025-02-08 15:28:13 -06:00
|
|
|
app.UseHttpsRedirection();
|
2025-02-08 14:07:29 -06:00
|
|
|
|
2025-03-11 21:21:16 -05:00
|
|
|
app.UseMiddlewares();
|
2025-02-08 15:28:13 -06:00
|
|
|
|
2025-02-08 14:07:29 -06:00
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
|
{
|
|
|
|
|
Log.Debug("App has been run in a development environment");
|
|
|
|
|
app.UseMigrationsEndPoint();
|
2025-03-11 19:32:38 -05:00
|
|
|
|
2025-02-08 14:07:29 -06:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
app.UseExceptionHandler("/Home/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();
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-11 21:21:16 -05:00
|
|
|
app.UseHangfire();
|
2025-02-08 14:07:29 -06:00
|
|
|
|
|
|
|
|
// app.UseHttpsRedirection();
|
|
|
|
|
app.UseStaticFiles();
|
|
|
|
|
|
2025-02-08 15:28:13 -06:00
|
|
|
app.UseCookiePolicy();
|
2025-02-08 14:07:29 -06:00
|
|
|
app.UseRouting();
|
|
|
|
|
|
|
|
|
|
app.UseAuthentication();
|
|
|
|
|
app.UseAuthorization();
|
2025-02-16 00:05:11 -06:00
|
|
|
app.UseAntiforgery();
|
2025-02-08 14:07:29 -06:00
|
|
|
|
2025-03-11 21:21:16 -05:00
|
|
|
app.UseSignalR();
|
2025-02-08 14:07:29 -06:00
|
|
|
|
2025-02-08 15:28:13 -06:00
|
|
|
app.UseStaticFiles();
|
|
|
|
|
|
2025-03-11 19:32:38 -05:00
|
|
|
app.MapScalar();
|
2025-03-11 21:21:16 -05:00
|
|
|
app.MapEndpoints();
|
2025-02-08 14:07:29 -06:00
|
|
|
|
2025-02-16 02:12:13 -06:00
|
|
|
app.MapRazorComponents<App>()
|
|
|
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
|
|
2025-03-11 21:21:16 -05:00
|
|
|
app.PrepareDirectories();
|
2025-02-08 14:07:29 -06:00
|
|
|
|
2025-03-11 21:21:16 -05:00
|
|
|
await app.MigrateDatabaseAsync();
|
|
|
|
|
await app.StartServerProcessesAsync();
|
2025-02-08 14:07:29 -06:00
|
|
|
|
2025-03-11 21:21:16 -05:00
|
|
|
app.GenerateThumbnails();
|
2025-02-08 15:28:13 -06:00
|
|
|
|
2025-01-02 11:40:15 +11:00
|
|
|
app.Run();
|
2025-02-08 14:07:29 -06:00
|
|
|
|