using Microsoft.EntityFrameworkCore; using RhSolutions.Models; using RhSolutions.Api.Services; using RhSolutions.Api.Middleware; using RhSolutions.MLModifiers; using Microsoft.OpenApi.Models; using System.Reflection; var builder = WebApplication.CreateBuilder(args); string dbHost = builder.Configuration["DB_HOST"] ?? "localhost", dbPort = builder.Configuration["DB_PORT"] ?? "5000", dbName = builder.Configuration["DB_DATABASE"] ?? "rhsolutions", dbUser = builder.Configuration["DB_USER"] ?? "chebser", dbPassword = builder.Configuration["DB_PASSWORD"] ?? "Rehau-987"; string connectionString = builder.Configuration["ConnectionsStrings:RhSolutionsLocal"] ?? $"Host={dbHost};Port={dbPort};Database={dbName};Username={dbUser};Password={dbPassword}"; builder.Services.AddDbContext(opts => { opts.UseNpgsql(connectionString); if (builder.Environment.IsDevelopment()) { opts.EnableSensitiveDataLogging(true); } }); builder.Services.AddScoped() .AddScoped(); builder.Services.AddModifiers(); builder.Services.AddControllers(); builder.Services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new OpenApiInfo { Version = "v1", Title = "RhSolutions API", Description = "API к базе данных артикулов РЕХАУ для поиска с помощью ML.NET и полнотестового поиска PostgreSQL", Contact = new OpenApiContact { Name = "Serghei Cebotari", Url = new Uri("https://cebotari.ru/"), Email = @"serghei@cebotari.ru" } }); var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename)); }); var app = builder.Build(); app.MapControllers(); app.UseMiddleware(); app.UseSwagger().UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "v1"); options.RoutePrefix = string.Empty; }); app.Run();