using System.Text.Json; using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Diagnostics.HealthChecks; // using Backend.Data var builder = WebApplication.CreateBuilder(args); builder.Services.AddControllers(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); builder.Services.AddHealthChecks(); builder.Services.AddCors(); //builder.Services.AddDbContext(options => // options.UseSqlite(builder.Configuration["ConnectionStrings:UserConnection"]) //); //builder.Services.AddScoped(); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.UseCors(p => p.WithOrigins("http://localhost:3000")); app.UseHttpsRedirection(); app.UseAuthorization(); app.MapHealthChecks("/health", new HealthCheckOptions { ResponseWriter = async (context, report) => { context.Response.ContentType = "application/json"; var payload = JsonSerializer.Serialize(new { status = report.Status == HealthStatus.Healthy ? "healthy" : "unhealthy", }); await context.Response.WriteAsync(payload); }, }); app.MapControllers(); app.Run();