Сборка бэк
This commit is contained in:
31
backend/src/Modules/Profiles/DependencyInjection.cs
Normal file
31
backend/src/Modules/Profiles/DependencyInjection.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Knot.Modules.Profiles.Application.Abstractions;
|
||||
using Knot.Modules.Profiles.Infrastructure.Database;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace Knot.Modules.Profiles;
|
||||
|
||||
public static class DependencyInjection
|
||||
{
|
||||
public static IServiceCollection AddProfilesModule(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddScoped<IProfileRepository, ProfileRepository>();
|
||||
services.AddScoped<IProfilesUnitOfWork, ProfilesUnitOfWork>();
|
||||
services.AddScoped<IAvatarStorageService, AvatarStorageService>();
|
||||
|
||||
// MongoDB Registration
|
||||
var mongoConnection = configuration.GetConnectionString("MongoConnection")
|
||||
?? configuration["MONGO_URL"]
|
||||
?? "mongodb://localhost:27017";
|
||||
|
||||
var mongoClient = new MongoClient(mongoConnection);
|
||||
var database = mongoClient.GetDatabase("knot_messager");
|
||||
services.AddSingleton<IMongoDatabase>(database);
|
||||
|
||||
services.AddMediatR(config =>
|
||||
config.RegisterServicesFromAssembly(typeof(DependencyInjection).Assembly));
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user