46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
|
using Hydra.Backend.Database;
|
||
|
using Hydra.Backend.Utils;
|
||
|
using Newtonsoft.Json.Serialization;
|
||
|
using Serilog;
|
||
|
|
||
|
var builder = WebApplication.CreateBuilder(args);
|
||
|
var config = builder.AddConfiguration(args);
|
||
|
builder.AddSerilog();
|
||
|
builder.WebHost.ConfigureKestrel(opts =>
|
||
|
{
|
||
|
// Requests are limited to a maximum of 2 MB.
|
||
|
// No valid request body will ever come close to this limit,
|
||
|
// but the limit is slightly higher to prevent valid requests from being rejected.
|
||
|
opts.Limits.MaxRequestBodySize = 2 * 1024 * 1024;
|
||
|
});
|
||
|
|
||
|
builder.Services
|
||
|
.AddDbContext<HydraContext>()
|
||
|
.AddCustomMiddleware()
|
||
|
.AddEndpointsApiExplorer()
|
||
|
.AddSwaggerGen()
|
||
|
.AddControllers()
|
||
|
.AddNewtonsoftJson(options =>
|
||
|
{
|
||
|
options.SerializerSettings.ContractResolver = new PatchRequestContractResolver
|
||
|
{
|
||
|
NamingStrategy = new SnakeCaseNamingStrategy()
|
||
|
};
|
||
|
});
|
||
|
|
||
|
|
||
|
var app = builder.Build();
|
||
|
|
||
|
app.UseSerilogRequestLogging();
|
||
|
app.UseRouting();
|
||
|
app.UseSwagger();
|
||
|
app.UseSwaggerUI();
|
||
|
app.UseCors();
|
||
|
app.UseCustomMiddleware();
|
||
|
app.MapControllers();
|
||
|
|
||
|
app.Urls.Clear();
|
||
|
app.Urls.Add(config.Address);
|
||
|
|
||
|
app.Run();
|
||
|
Log.CloseAndFlush();
|