using BudgetApp.Services; using BudgetApp.Storage; using Microsoft.EntityFrameworkCore; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); var connectionString = builder.Configuration.GetSection("ConnectionStrings").GetValue("MainDatabase"); builder.Services.AddDbContext(options => options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString))); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddCors(options => { options.AddPolicy("AllowAll", policy => { policy .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); }); }); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } if (!app.Environment.IsProduction()) { app.UseHttpsRedirection(); } app.UseCors("AllowAll"); app.UseAuthorization(); app.MapGet("/ping", () => Results.Ok(new { ok = true, time = DateTime.UtcNow })); app.MapControllers(); app.Run();