diff options
Diffstat (limited to 'src/marlin.web/Program.cs')
| -rw-r--r-- | src/marlin.web/Program.cs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/marlin.web/Program.cs b/src/marlin.web/Program.cs new file mode 100644 index 0000000..cf330b2 --- /dev/null +++ b/src/marlin.web/Program.cs @@ -0,0 +1,42 @@ +using marlin.web.Data; +using marlin.web.Services; +using Microsoft.EntityFrameworkCore; + +DotNetEnv.Env.NoClobber().TraversePath().Load(); + +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddDbContext<ApplicationDbContext>(options => options + .UseNpgsql(builder.Configuration.GetConnectionString("Master")) + .UseSnakeCaseNamingConvention()); + +builder.Services.AddHostedService<DatabaseUpgrader>(); +builder.Services.AddHostedService<VersionControlSyncService>(); + +// Add services to the container. +builder.Services.AddControllersWithViews(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (!app.Environment.IsDevelopment()) +{ + 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(); +} + +app.UseHttpsRedirection(); +app.UseRouting(); + +app.UseAuthorization(); + +app.MapStaticAssets(); + +app + .MapControllerRoute( + name: "default", + pattern: "{controller=Home}/{action=Index}/{id?}") + .WithStaticAssets(); + +app.Run();
\ No newline at end of file |
