using Expedience.Api.Consumers; using Expedience.Api.Db; using Expedience.Api.Encryption; using MassTransit; using Microsoft.EntityFrameworkCore; using System.Reflection; var builder = WebApplication.CreateBuilder(args); // Add services to the container. var connectionString = builder.Configuration.GetConnectionString("Expedience"); builder.Services.AddDbContext(options => options.UseNpgsql(connectionString)); builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); var rabbitMqHost = builder.Configuration.GetSection("RabbitMq")["Host"]; builder.Services.AddMassTransit(opt => { opt.AddConsumersFromNamespaceContaining(); opt.UsingRabbitMq((context, cfg) => { cfg.Host(rabbitMqHost); cfg.ConfigureEndpoints(context); }); }); builder.Services.AddSingleton(); var app = builder.Build(); var scope = app.Services.CreateScope(); var dbContext = scope.ServiceProvider.GetRequiredService(); dbContext.Database.EnsureCreated(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.Run();