Project Update

This commit is contained in:
2026-03-05 04:52:15 +00:00
parent a99a477985
commit 2bbbbc746f
15 changed files with 551 additions and 93 deletions

View File

@@ -1,10 +1,18 @@
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<IRecipeService, RecipeService>();
builder.Services.AddControllers();
builder.Services.AddControllers()
.AddJsonOptions(options => {
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
});
builder.Services.AddOpenApi();
builder.Services.AddCors(options =>
@@ -17,7 +25,20 @@ builder.Services.AddCors(options =>
});
});
builder.Services.AddDbContext<ApplicationDbContext>(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<ApplicationDbContext>();
db.Database.EnsureCreated();
}
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseCors("AllowAll");
if (app.Environment.IsDevelopment())
@@ -26,4 +47,5 @@ if (app.Environment.IsDevelopment())
}
app.MapControllers();
app.MapFallbackToFile("index.html");
app.Run();