using Femto.Common.Infrastructure.Outbox; using Femto.Modules.Authentication.Data; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; namespace Femto.Modules.Authentication; public static class Module { public static void UseIdentityModule(this IServiceCollection services, string connectionString) { services.AddDbContext( builder => { builder.UseNpgsql(connectionString); builder.UseSnakeCaseNamingConvention(); }); services.AddMediatR(c => c.RegisterServicesFromAssembly(typeof(Module).Assembly)); services.AddDbContext(builder => { builder.UseNpgsql( connectionString, o => { o.MapEnum("outbox_status"); } ); builder.UseSnakeCaseNamingConvention(); var loggerFactory = LoggerFactory.Create(b => { // b.AddConsole(); // .AddFilter( // (category, level) => // category == DbLoggerCategory.Database.Command.Name // && level == LogLevel.Debug // ); }); builder.UseLoggerFactory(loggerFactory); builder.EnableSensitiveDataLogging(); }); // services.AddOutbox(); services.AddMediatR(c => { c.RegisterServicesFromAssembly(typeof(Module).Assembly); }); services.AddTransient, Outbox>(); } }