Foxnouns.NET/Foxnouns.Backend/Program.cs

41 lines
867 B
C#
Raw Normal View History

2024-05-27 15:53:54 +02:00
using Foxnouns.Backend.Database;
using Serilog;
using Foxnouns.Backend.Extensions;
using Newtonsoft.Json.Serialization;
var builder = WebApplication.CreateBuilder(args);
var config = builder.AddConfiguration();
builder.AddSerilog(config.LogEventLevel);
builder.Services
.AddControllers()
.AddNewtonsoftJson(options =>
options.SerializerSettings.ContractResolver = new DefaultContractResolver
{
NamingStrategy = new SnakeCaseNamingStrategy()
});
builder.Services
.AddDbContext<DatabaseContext>()
.AddSnowflakeGenerator()
.AddEndpointsApiExplorer()
.AddSwaggerGen();
var app = builder.Build();
app.UseSerilogRequestLogging();
app.UseRouting();
app.UseSwagger();
app.UseSwaggerUI();
app.UseCors();
app.MapControllers();
app.Urls.Clear();
app.Urls.Add(config.Address);
app.Run();
Log.CloseAndFlush();