Files
nashel-backend/src/Modules/Identity/Infrastructure/DependencyInjection.cs
Халимов Рустам 65b86e718d Fix swagger
2026-02-10 00:38:21 +03:00

39 lines
1.4 KiB
C#

using MediatR;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Nashel.BuildingBlocks.Application.Abstractions;
using Nashel.BuildingBlocks.Application.Behaviors;
using Nashel.Modules.Identity.Application.Commands;
using Nashel.Modules.Identity.Domain.Repositories;
using Nashel.Modules.Identity.Domain.Services;
using Nashel.Modules.Identity.Infrastructure.Persistence;
using Nashel.Modules.Identity.Infrastructure.Repositories;
using Nashel.Modules.Identity.Infrastructure.Services;
namespace Nashel.Modules.Identity.Infrastructure;
public static class DependencyInjection
{
public static IServiceCollection AddIdentityModule(this IServiceCollection services, IConfiguration configuration)
{
services.AddScoped<IAccountRepository, AccountRepository>();
services.AddScoped<IJwtTokenGenerator, JwtTokenGenerator>();
services.AddScoped<ICurrentUserService, CurrentUserService>();
services.AddHttpContextAccessor();
services.AddMediatR(cfg =>
{
cfg.RegisterServicesFromAssembly(typeof(RegisterUserCommand).Assembly);
cfg.AddBehavior(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
});
services.AddDbContext<IdentityDbContext>(options =>
{
options.UseNpgsql(configuration.GetConnectionString("DefaultConnection"));
});
return services;
}
}