2024-04-22 16:54:28 -05:00
using API.Services ;
2024-04-16 18:38:11 -05:00
using DAL.Contexts ;
using Microsoft.EntityFrameworkCore ;
2024-04-22 18:04:14 -05:00
using Serilog ;
2024-04-16 18:38:11 -05:00
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 ) ;
} ) ;
2024-04-22 18:04:14 -05:00
builder . Host . UseSerilog ( ( context , configuration ) = > configuration . ReadFrom . Configuration ( context . Configuration ) ) ;
2024-04-22 16:54:28 -05:00
builder . Services . AddDbContext < SASGContext > ( options = > { options . UseMySQL ( builder . Configuration [ "connectionString" ] ? ? throw new InvalidOperationException ( "Connection String is null" ) ) ; } ) ;
builder . Services . AddTransient < ColorService > ( ) ;
2024-04-22 18:04:14 -05:00
builder . Services . AddTransient < EventService > ( ) ;
builder . Services . AddTransient < GrantService > ( ) ;
builder . Services . AddTransient < ImageService > ( ) ;
builder . Services . AddTransient < PermissionService > ( ) ;
builder . Services . AddTransient < SavedEventService > ( ) ;
builder . Services . AddTransient < UserService > ( ) ;
2024-04-16 18:38:11 -05:00
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 ( ) ;
}
}
2024-04-22 16:54:28 -05:00
}