- ServiceRepository: IServiceRepository 구현 (GetByServiceCode, GetByApiKey) - ServiceCodeMiddleware: X-Service-Code 헤더 검증, DB 조회, 서비스 상태 확인 - ApiKeyMiddleware: /v1/in/device/* 경로 X-API-KEY 검증 - ApplicationBuilderExtensions: 미들웨어 파이프라인 12~13번 등록 - DependencyInjection: IServiceRepository DI 등록 Closes #32
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using SPMS.Application.Interfaces;
|
|
using SPMS.Domain.Interfaces;
|
|
using SPMS.Infrastructure.Auth;
|
|
using SPMS.Infrastructure.Persistence;
|
|
using SPMS.Infrastructure.Persistence.Repositories;
|
|
using SPMS.Infrastructure.Security;
|
|
|
|
namespace SPMS.Infrastructure;
|
|
|
|
public static class DependencyInjection
|
|
{
|
|
public static IServiceCollection AddInfrastructure(
|
|
this IServiceCollection services,
|
|
IConfiguration configuration)
|
|
{
|
|
// DbContext
|
|
var connectionString = configuration.GetConnectionString("DefaultConnection");
|
|
services.AddDbContext<AppDbContext>(options =>
|
|
options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)));
|
|
|
|
// UnitOfWork & Repositories
|
|
services.AddScoped<IUnitOfWork, UnitOfWork>();
|
|
services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
|
|
services.AddScoped<IServiceRepository, ServiceRepository>();
|
|
|
|
// External Services
|
|
services.AddScoped<IJwtService, JwtService>();
|
|
services.AddSingleton<IE2EEService, E2EEService>();
|
|
|
|
return services;
|
|
}
|
|
}
|