femto-backend/Femto.Modules.Authentication/Module.cs

57 lines
No EOL
1.8 KiB
C#

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<AuthenticationContext>(
builder =>
{
builder.UseNpgsql(connectionString);
builder.UseSnakeCaseNamingConvention();
});
services.AddMediatR(c => c.RegisterServicesFromAssembly(typeof(Module).Assembly));
services.AddDbContext<AuthenticationContext>(builder =>
{
builder.UseNpgsql(
connectionString,
o =>
{
o.MapEnum<OutboxEntryStatus>("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<AuthenticationContext>();
services.AddMediatR(c =>
{
c.RegisterServicesFromAssembly(typeof(Module).Assembly);
});
services.AddTransient<Outbox<AuthenticationContext>, Outbox<AuthenticationContext>>();
}
}