add a bunch of stuff copied from Foxchat.NET

This commit is contained in:
sam 2024-05-28 15:29:18 +02:00
parent f4c0a40259
commit 6114f384a0
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
21 changed files with 1216 additions and 35 deletions

View file

@ -1,6 +1,8 @@
using Foxnouns.Backend;
using Foxnouns.Backend.Database;
using Serilog;
using Foxnouns.Backend.Extensions;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Serialization;
var builder = WebApplication.CreateBuilder(args);
@ -15,21 +17,31 @@ builder.Services
options.SerializerSettings.ContractResolver = new DefaultContractResolver
{
NamingStrategy = new SnakeCaseNamingStrategy()
});
})
.ConfigureApiBehaviorOptions(options =>
{
options.InvalidModelStateResponseFactory = actionContext => new BadRequestObjectResult(
new ApiError.BadRequest("Bad request", actionContext.ModelState).ToJson()
);
});
builder.Services
.AddDbContext<DatabaseContext>()
.AddSnowflakeGenerator()
.AddCustomServices()
.AddCustomMiddleware()
.AddEndpointsApiExplorer()
.AddSwaggerGen();
var app = builder.Build();
await app.Initialize(args);
app.UseSerilogRequestLogging();
app.UseRouting();
app.UseSwagger();
app.UseSwaggerUI();
app.UseCors();
app.UseCustomMiddleware();
app.MapControllers();
app.Urls.Clear();
@ -37,4 +49,4 @@ app.Urls.Add(config.Address);
app.Run();
Log.CloseAndFlush();
Log.CloseAndFlush();