x-lab-lbq-technical-test/backend/LeedsBeerQuest.API/LeedsBeerQuest.API/Program.cs

39 lines
867 B
C#

using LeedsBeerQuest.API;
using LeedsBeerQuest.API.Data.Contexts;
using LeedsBeerQuest.API.Data.Seed;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// App services
builder.Services.AddServiceDependencies();
var app = builder.Build();
#if LBQ_SEED_DATA
var dbContext = app.Services.GetRequiredService<LeedsBeerQuestDbContext>();
var seeder = new LeedsBeerQuestSeeder(dbContext!, "");
seeder.Seed();
#endif
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();