using JOBot.Backend.DAL.Context; using JOBot.Backend.Infrastructure.Config; using JOBot.Backend.Services; using JOBot.Backend.Services.gRPC; using JOBot.Infrastructure.Config; using Microsoft.EntityFrameworkCore; using RabbitMQ.Client; namespace JOBot.Backend; public class Startup(IConfiguration configuration) { private IConfiguration Configuration { get; } = configuration; public void ConfigureServices(IServiceCollection services) { services.AddGrpc(); services.AddGrpcReflection(); services.AddControllers(); services.AddLogging(); services.AddDbContext(options => options.UseNpgsql(Configuration.GetConnectionString("PostgreSQL"))); services.AddSingleton(x => { var rabbitMqConnection = new ConnectionFactory { HostName = "rabbitmq" }.CreateConnectionAsync().Result; var channel = rabbitMqConnection.CreateChannelAsync().Result; channel.QueueDeclareAsync( RabbitQueues.AuthQueue, false, false, false, arguments: null).Wait(); return channel; }); services.Configure(Configuration.GetSection(HeadHunterConfig.SectionName)); services.AddScoped(); } public void Configure(WebApplication app, IWebHostEnvironment env) { app.MapGrpcReflectionService().AllowAnonymous(); app.MapGrpcService(); app.MapControllers(); } }