You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.8 KiB
70 lines
1.8 KiB
using Exsersewo.Common.Utilities;
|
|
using Kynareth.Helpers;
|
|
using Kynareth.Helpers.AmongUs;
|
|
using Kynareth.Managers;
|
|
using Kynareth.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using StatsdClient;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.WebHost.UseKestrel();
|
|
|
|
HttpWebClient.UserAgent = "IBrowse/2.4 (AmigaOS 3.9; 68K)";
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddControllers();
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services
|
|
.AddEndpointsApiExplorer()
|
|
.AddSwaggerGen();
|
|
|
|
builder.Services
|
|
.AddAuthentication();
|
|
|
|
builder.Services.AddDbContext<KynarethDbContext>(options =>
|
|
{
|
|
var connStr = builder.Configuration.GetConnectionString("Database");
|
|
|
|
var serverVersion = ServerVersion.AutoDetect(connStr);
|
|
|
|
options.UseMySql(connStr, serverVersion, x => x.EnableRetryOnFailure());
|
|
options.UseLazyLoadingProxies();
|
|
}, contextLifetime: ServiceLifetime.Transient, optionsLifetime: ServiceLifetime.Singleton);
|
|
|
|
builder.Services.AddSingleton(builder.Environment);
|
|
builder.Services.AddSingleton(builder.Configuration);
|
|
builder.Services.AddSingleton<ImageManipulator>();
|
|
builder.Services.AddSingleton<ImageGenerator>();
|
|
builder.Services.AddSingleton<ImageMagiker>();
|
|
builder.Services.AddSingleton<AmongUsGenerator>();
|
|
|
|
var app = builder.Build();
|
|
|
|
RequestHelper.Configure(app);
|
|
|
|
var dogstatsdConfig = new StatsdConfig
|
|
{
|
|
StatsdServerName = "127.0.0.1",
|
|
StatsdPort = 8125,
|
|
};
|
|
|
|
DogStatsd.Configure(dogstatsdConfig);
|
|
|
|
// Configure the HTTP request pipeline.
|
|
//if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseStaticFiles();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Services.GetService<ILogger<Program>>().LogInformation($"Ready and waiting requests @ {string.Join(";", app.Urls)}");
|
|
|
|
app.Run(); |