wip
This commit is contained in:
parent
1ecaf64dea
commit
cb9d5e332e
11 changed files with 72 additions and 69 deletions
|
@ -0,0 +1,8 @@
|
|||
using Femto.Modules.Authentication.Data;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Femto.Modules.Authentication.Application;
|
||||
|
||||
internal class AuthenticationModule(IHost host) : IAuthenticationModule
|
||||
{
|
||||
}
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
namespace Femto.Modules.Authentication.Application;
|
||||
|
||||
public interface IAuthenticationModule
|
||||
{
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
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>>();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue