This commit is contained in:
john 2025-05-11 23:43:38 +02:00
parent 1ecaf64dea
commit cb9d5e332e
11 changed files with 72 additions and 69 deletions

View file

@ -0,0 +1,44 @@
using Femto.Common.Infrastructure.Outbox;
using Femto.Modules.Authentication.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Femto.Modules.Authentication.Application;
public static class AuthenticationStartup
{
public static void InitializeAuthenticationModule(this IServiceCollection rootContainer, string connectionString)
{
var hostBuilder = Host.CreateDefaultBuilder();
hostBuilder.ConfigureServices(services => ConfigureServices(services, connectionString));
var host = hostBuilder.Build();
rootContainer.AddScoped<IAuthenticationModule>(_ => new AuthenticationModule(host));
}
private static void ConfigureServices(IServiceCollection services, string connectionString)
{
services.AddDbContext<AuthenticationContext>(
builder =>
{
builder.UseNpgsql(connectionString);
builder.UseSnakeCaseNamingConvention();
});
services.AddMediatR(c => c.RegisterServicesFromAssembly(typeof(AuthenticationStartup).Assembly));
services.AddDbContext<AuthenticationContext>(builder =>
{
builder.UseNpgsql();
builder.UseSnakeCaseNamingConvention();
builder.EnableSensitiveDataLogging();
});
services.AddMediatR(c =>
{
c.RegisterServicesFromAssembly(typeof(AuthenticationStartup).Assembly);
});
}
}