2026-02-08 18:00:24 +01:00
|
|
|
using FluentValidation;
|
2026-02-15 19:06:09 +01:00
|
|
|
using IdentityShroud.Api.Mappers;
|
2026-08-18 07:40:24 +02:00
|
|
|
using IdentityShroud.Core;
|
2026-03-16 19:15:04 +01:00
|
|
|
using IdentityShroud.Core.EFCore;
|
2026-08-18 07:40:24 +02:00
|
|
|
using IdentityShroud.GraphQL;
|
2026-02-06 19:58:01 +01:00
|
|
|
using Serilog;
|
|
|
|
|
using Serilog.Formatting.Json;
|
|
|
|
|
|
|
|
|
|
// Initial logging until we can set it up from Configuration
|
|
|
|
|
|
2026-08-18 07:40:24 +02:00
|
|
|
namespace IdentityShroud.Api;
|
2026-02-06 19:58:01 +01:00
|
|
|
|
2026-08-18 07:40:24 +02:00
|
|
|
public class Program
|
2026-02-06 19:58:01 +01:00
|
|
|
{
|
2026-08-18 07:40:24 +02:00
|
|
|
public static void Main(string[] args)
|
2026-02-06 19:58:01 +01:00
|
|
|
{
|
2026-08-18 07:40:24 +02:00
|
|
|
Log.Logger = new LoggerConfiguration()
|
|
|
|
|
.Enrich.FromLogContext()
|
|
|
|
|
.WriteTo.Console(new JsonFormatter())
|
|
|
|
|
.CreateLogger();
|
2026-02-06 19:58:01 +01:00
|
|
|
|
2026-08-18 07:40:24 +02:00
|
|
|
var applicationBuilder = WebApplication.CreateSlimBuilder(args);
|
|
|
|
|
ConfigureBuilder(applicationBuilder);
|
|
|
|
|
var application = applicationBuilder.Build();
|
|
|
|
|
ConfigureApplication(application);
|
|
|
|
|
application.Run();
|
|
|
|
|
}
|
2026-02-06 19:58:01 +01:00
|
|
|
|
2026-08-18 07:40:24 +02:00
|
|
|
private static void ConfigureBuilder(WebApplicationBuilder builder)
|
2026-02-06 19:58:01 +01:00
|
|
|
{
|
2026-08-18 07:40:24 +02:00
|
|
|
var services = builder.Services;
|
|
|
|
|
var configuration = builder.Configuration;
|
|
|
|
|
|
|
|
|
|
services.AddOptions<DbConfiguration>().Bind(configuration.GetSection("db"));
|
|
|
|
|
|
|
|
|
|
// services.ConfigureHttpJsonOptions(options =>
|
|
|
|
|
// {
|
|
|
|
|
// options.SerializerOptions.TypeInfoResolverChain.Insert(0, IdentityShroud.Api.AppJsonSerializerContext.Default);
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
services.AddScoped<KeyMapper>();
|
|
|
|
|
|
|
|
|
|
services.AddValidatorsFromAssemblyContaining<RealmCreateRequestValidator>();
|
|
|
|
|
|
|
|
|
|
services.AddHttpContextAccessor();
|
|
|
|
|
services.AddOpenApi();
|
|
|
|
|
services.AddExceptionHandler<GlobalExceptionHandler>();
|
|
|
|
|
services.AddProblemDetails();
|
|
|
|
|
|
|
|
|
|
services
|
|
|
|
|
.AddCore()
|
|
|
|
|
.AddIdentityShroudGraphQL();
|
|
|
|
|
|
|
|
|
|
builder.Host.UseSerilog((context, services, configuration) => configuration
|
|
|
|
|
.Enrich.FromLogContext()
|
|
|
|
|
//.Enrich.With<UserEnricher>()
|
|
|
|
|
.ReadFrom.Configuration(context.Configuration));
|
2026-02-06 19:58:01 +01:00
|
|
|
}
|
2026-02-08 18:00:24 +01:00
|
|
|
|
2026-08-18 07:40:24 +02:00
|
|
|
private static void ConfigureApplication(WebApplication app)
|
|
|
|
|
{
|
|
|
|
|
app.UseExceptionHandler();
|
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
|
{
|
|
|
|
|
app.MapOpenApi();
|
|
|
|
|
}
|
|
|
|
|
app.UseSerilogRequestLogging();
|
|
|
|
|
app.MapApis();
|
|
|
|
|
app.MapIdentityShroudGraphQL();
|
|
|
|
|
|
|
|
|
|
// app.UseRouting();
|
|
|
|
|
// app.MapControllers();
|
|
|
|
|
}
|
|
|
|
|
}
|