oliverbooth.dev/OliverBooth/Program.cs

58 lines
1.7 KiB
C#
Raw Normal View History

2023-08-08 00:34:15 +01:00
using Markdig;
2023-08-12 20:40:46 +01:00
using OliverBooth.Common;
using OliverBooth.Common.Extensions;
2023-08-13 13:28:25 +01:00
using OliverBooth.Common.Markdown;
using OliverBooth.Common.Services;
using OliverBooth.Data;
using OliverBooth.Markdown.Timestamp;
2023-08-06 15:56:08 +01:00
using OliverBooth.Services;
2023-08-12 21:06:48 +01:00
using Serilog;
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.WriteTo.File("logs/latest.log", rollingInterval: RollingInterval.Day)
.CreateLogger();
2023-08-06 15:56:08 +01:00
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddTomlFile("data/config.toml", true, true);
2023-08-06 15:56:08 +01:00
builder.Logging.ClearProviders();
2023-08-12 21:06:48 +01:00
builder.Logging.AddSerilog();
2023-08-12 20:40:46 +01:00
builder.Services.ConfigureOptions<OliverBoothConfigureOptions>();
builder.Services.AddSingleton<ITemplateService, TemplateService>();
builder.Services.AddSingleton(provider => new MarkdownPipelineBuilder()
.Use<TimestampExtension>()
.Use(new TemplateExtension(provider.GetRequiredService<ITemplateService>()))
2023-08-08 00:34:15 +01:00
.UseAdvancedExtensions()
.UseBootstrap()
2023-08-09 23:19:39 +01:00
.UseEmojiAndSmiley()
2023-08-09 23:19:29 +01:00
.UseSmartyPants()
2023-08-08 00:34:15 +01:00
.Build());
2023-08-06 15:56:08 +01:00
builder.Services.AddDbContextFactory<WebContext>();
2023-08-06 15:55:12 +01:00
builder.Services.AddRazorPages().AddRazorRuntimeCompilation();
2023-08-05 21:01:47 +01:00
builder.Services.AddControllersWithViews();
builder.Services.AddRouting(options => options.LowercaseUrls = true);
2023-05-26 19:05:44 +01:00
builder.WebHost.AddCertificateFromEnvironment(2845, 5049);
2023-08-10 23:33:15 +01:00
WebApplication app = builder.Build();
2023-05-26 19:05:44 +01:00
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();
app.UseAuthorization();
2023-08-05 20:58:03 +01:00
2023-08-05 21:01:47 +01:00
app.MapControllers();
2023-05-26 19:05:44 +01:00
app.MapRazorPages();
app.Run();