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 async Task ConfigureServices(IServiceCollection services) { services.AddGrpc(); services.AddGrpcReflection(); services.AddControllers(); services.AddLogging(); var rabbitMqConnection = await new ConnectionFactory { HostName = "rabbitmq" }.CreateConnectionAsync(); var channel = await rabbitMqConnection.CreateChannelAsync(); await channel.QueueDeclareAsync( RabbitQueues.AuthQueue, false, false, false, arguments: null); services.AddSingleton(channel); services.AddDbContext(options => options.UseNpgsql(Configuration.GetConnectionString("PostgreSQL"))); services.Configure(Configuration.GetSection(HeadHunterConfig.SectionName)); services.AddScoped(); } public void Configure(WebApplication app, IWebHostEnvironment env) { app.MapGrpcReflectionService().AllowAnonymous(); app.MapGrpcService(); app.MapControllers(); } }