using System.Text.Json; using Microsoft.EntityFrameworkCore; using Hua.Todo.Application; using Hua.Todo.Application.CloudSync; using Hua.Todo.Application.DynamicApi; using Hua.Todo.Application.DynamicApi.Swagger; using Hua.Todo.Application.Interfaces; using Hua.Todo.Application.Models; var builder = WebApplication.CreateBuilder(args); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(options => { options.DocumentFilter(); }); builder.Services.AddCloudSyncServer(); builder.Services.AddApplicationServices("Data Source=Hua.Todo.db"); builder.Services.AddCors(options => { options.AddPolicy("AllowAll", policy => { policy.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); }); }); var app = builder.Build(); // Apply database migrations using (var scope = app.Services.CreateScope()) { var dbContext = scope.ServiceProvider.GetRequiredService(); dbContext.Database.Migrate(); } if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.UseHttpsRedirection(); app.UseCors("AllowAll"); app.UseAuthentication(); app.UseAuthorization(); app.MapCloudSyncEndpoints(); app.UseDynamicApi(); app.Run();