using CartriX.Api.Interfaces; using CartriX.Api.Services; using CartriX.Api.Classes; using Microsoft.EntityFrameworkCore; using Scalar.AspNetCore; using Microsoft.EntityFrameworkCore.Internal; var builder = WebApplication.CreateBuilder(args); builder.Services.AddControllers(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddSingleton(); builder.Services.AddHostedService(); builder.Services.AddCors(options => { options.AddPolicy("AllowAll", policy => { policy .AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod(); }); }); builder.WebHost.UseUrls( "http://localhost:5197" ); builder.Services.AddOpenApi(options => { options.AddDocumentTransformer((document, context, cancelationToken) => { document.Info = new() { Title = "CartriX API" }; return Task.CompletedTask; }); }); builder.Services.AddDbContext(options => { options.UseSqlite( builder.Configuration.GetConnectionString("DevSQL")); }); var app = builder.Build(); app.UseRouting(); app.UseCors("AllowAll"); if (app.Environment.IsDevelopment()) { app.MapOpenApi(); app.MapScalarApiReference(options => { options.HideSearch = true; options.HideModels = true; options.Layout = ScalarLayout.Modern; options.DefaultOpenAllTags = false; options.Agent = new ScalarAgentOptions { Disabled = true }; options.Title = "CartriX API Documentation"; options.Theme = ScalarTheme.DeepSpace; }); } app.MapControllers(); app.Run();