using API.Authentication; using API.Authentication.Interfaces; using API.Services; using DAL.Contexts; using Microsoft.EntityFrameworkCore; using Serilog; using System.Reflection; using InvalidOperationException = System.InvalidOperationException; namespace API { internal class Program { public static void Main(string[] args) { WebApplicationBuilder builder = WebApplication.CreateBuilder(args); ConfigurationManager configManager = builder.Configuration; builder.Services.AddControllers(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(options => { string xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; string xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); options.IncludeXmlComments(xmlPath, true); }); builder.Host.UseSerilog((context, configuration) => configuration.ReadFrom.Configuration(context.Configuration)); builder.Services.AddDbContext(options => { options.UseMySQL(builder.Configuration["connectionString"] ?? throw new InvalidOperationException("Connection String is null")); }); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); WebApplication app = builder.Build(); if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.UseCookiePolicy(new CookiePolicyOptions { MinimumSameSitePolicy = SameSiteMode.Strict }); app.UseHttpsRedirection(); app.MapControllers(); app.Run(); } } }