using CodeBase.Orchestrators; using CodeBase.Parsers; using CodeBase.Repositories; using CodeBase.Services; using Microsoft.Build.Locator; using Neo4j.Driver; if (!MSBuildLocator.IsRegistered) { MSBuildLocator.RegisterDefaults(); } var builder = WebApplication.CreateBuilder(args); builder.Services.AddSingleton(); // Add services to the container. builder.Services.AddSingleton(sp => GraphDatabase.Driver( "bolt://localhost:7687", AuthTokens.Basic("neo4j", "password123") ) ); builder.Services.AddSingleton(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddScoped(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddControllers(); builder.Services.AddSwaggerGen(); var app = builder.Build(); using (var scope = app.Services.CreateScope()) { var dbInit = scope.ServiceProvider.GetRequiredService(); await dbInit.InitializeAsync(); } // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); using (var scope = app.Services.CreateScope()) { var graphRepo = scope.ServiceProvider.GetRequiredService(); Console.WriteLine("Проверяем и создаем векторный индекс в Neo4j..."); await graphRepo.InitializeDbAsync(); Console.WriteLine("Индекс готов!"); } app.Run();