using Seasoned.Backend.Services; using Microsoft.AspNetCore.HttpOverrides; using System.Text.Json; using Microsoft.EntityFrameworkCore; using Seasoned.Backend.Data; var builder = WebApplication.CreateBuilder(args); builder.Services.AddScoped(); builder.Services.AddControllers() .AddJsonOptions(options => { options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; }); builder.Services.AddOpenApi(); builder.Services.AddCors(options => { options.AddPolicy("AllowAll", policy => { policy.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); }); }); builder.Services.AddDbContext(options => options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection"), o => o.UseVector())); var app = builder.Build(); using (var scope = app.Services.CreateScope()) { var db = scope.ServiceProvider.GetRequiredService(); db.Database.EnsureCreated(); } app.UseDefaultFiles(); app.UseStaticFiles(); app.UseCors("AllowAll"); if (app.Environment.IsDevelopment()) { app.MapOpenApi(); } app.MapControllers(); app.MapFallbackToFile("index.html"); app.Run();