2026-02-02 04:48:10 -06:00
|
|
|
namespace FiscalOS.Infra.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
public static class ServiceCollectionExtensions
|
|
|
|
|
{
|
|
|
|
|
public static IServiceCollection AddInfrastructure(this IServiceCollection services)
|
|
|
|
|
{
|
2026-02-03 21:03:41 -06:00
|
|
|
services.AddSingleton<IAuthorizationMiddlewareResultHandler, ProblemDetailsAuthResultHandler>();
|
2026-02-12 20:48:49 -06:00
|
|
|
|
|
|
|
|
services.AddHttpClient();
|
2026-02-02 13:18:15 -06:00
|
|
|
services.AddSingleton(TimeProvider.System);
|
2026-02-06 06:46:01 -06:00
|
|
|
services.AddSingleton<IFileSystem, FileSystem>();
|
2026-02-03 11:06:44 -06:00
|
|
|
|
2026-02-02 15:41:47 -06:00
|
|
|
services.ConfigureOptions<JwtOptionsSetup>();
|
2026-02-03 11:06:44 -06:00
|
|
|
services.ConfigureOptions<JwtBearerOptionsSetup>();
|
|
|
|
|
|
2026-02-06 06:46:01 -06:00
|
|
|
services.AddSingleton<ITokenGenerator>(TokenGenerator.From);
|
|
|
|
|
services.AddSingleton<IPasswordHasher>(PasswordHasher.From);
|
|
|
|
|
|
|
|
|
|
services.ConfigureOptions<FileKeyRingOptionsSetup>();
|
|
|
|
|
services.AddSingleton<IKeyRing>(FileKeyRing.From);
|
|
|
|
|
services.AddSingleton<IEncryptor>(Encryptor.From);
|
2026-02-03 11:06:44 -06:00
|
|
|
|
2026-02-02 04:48:10 -06:00
|
|
|
services.ConfigureOptions<AppDbContextOptionsSetup>();
|
|
|
|
|
services.AddDbContext<AppDbContext>();
|
|
|
|
|
services.AddHostedService<MigrationService>();
|
2026-02-03 11:06:44 -06:00
|
|
|
|
2026-02-12 20:48:49 -06:00
|
|
|
services.ConfigureOptions<PlaidClientOptionsSetup>();
|
|
|
|
|
services.AddSingleton(static sp =>
|
|
|
|
|
{
|
|
|
|
|
var factory = sp.GetRequiredService<IHttpClientFactory>();
|
|
|
|
|
var logger = sp.GetRequiredService<ILogger<PlaidClient>>();
|
|
|
|
|
var clientOptions = sp.GetRequiredService<IOptions<PlaidClientOptions>>();
|
|
|
|
|
var options = clientOptions.Value.ToPlaidOptions();
|
|
|
|
|
return new PlaidClient(options, factory, logger);
|
|
|
|
|
});
|
|
|
|
|
services.AddSingleton(PlaidService.From);
|
|
|
|
|
|
2026-02-02 04:48:10 -06:00
|
|
|
return services;
|
|
|
|
|
}
|
|
|
|
|
}
|