shopping-assistant-api/ShoppingAssistantApi.Api/Program.cs
2023-10-29 01:54:43 +00:00

50 lines
1.5 KiB
C#

using ShoppingAssistantApi.Application.ApplicationExtentions;
using ShoppingAssistantApi.Persistance.PersistanceExtentions;
using ShoppingAssistantApi.Infrastructure.InfrastructureExtentions;
using ShoppingAssistantApi.Api.ApiExtentions;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
var appConfig = Environment.GetEnvironmentVariable("APP_CONFIG") ?? builder.Configuration.GetConnectionString("AppConfig");
builder.Configuration.AddAzureAppConfiguration(appConfig);
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddJWTTokenAuthentication(builder.Configuration);
builder.Services.AddMapper();
builder.Services.AddInfrastructure();
builder.Services.AddServices();
builder.Services.AddHttpClient(builder.Configuration);
builder.Services.AddGraphQl();
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthentication();
app.UseAuthorization();
app.AddGlobalUserMiddleware();
app.MapGraphQL();
app.MapControllers();
// using var scope = app.Services.CreateScope();
// var serviceProvider = scope.ServiceProvider;
// var initializer = new DbInitialaizer(serviceProvider);
// await initializer.InitialaizeDb(CancellationToken.None);
app.Run();
public partial class Program { }