You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
PortfolioLink/backend/Program.cs

47 lines
1.3 KiB

using Models;
using Serilog;
//TODO Make this configurable from appsettings
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.Console()
.WriteTo.File("logs/portfolioportal.txt", rollingInterval: RollingInterval.Day)
.CreateLogger();
Log.Information("Starting Portfolio Portal ASP.NET Core Backend");
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers()
.AddNewtonsoftJson();
builder.Services.AddDbContext<PortfolioPortalDbContext>();
builder.Logging.AddSerilog();
var app = builder.Build();
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
// Custom JWT handling with Ed25519 validation
app.UseMiddleware<JwtAuthenticationMiddleware>();
// If this is the production build make sure we're always using HTTPS
if (!app.Environment.IsDevelopment())
{
// If an unhandled exception is encountered redirect to Error endpoint
//TODO Create an error endpoint
app.UseExceptionHandler("/Error");
app.UseHsts();
}
else
{
// Generates a rich error page with detailed information such as the exception type, message, stack trace, request details, and more
app.UseDeveloperExceptionPage();
}
app.Run();