This commit is contained in:
Flaminel
2025-05-14 22:42:52 +03:00
parent 461e935128
commit 69788d55d2
11 changed files with 1141 additions and 7 deletions

View File

@@ -0,0 +1,51 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
namespace Executable.DependencyInjection;
public static class ApiDI
{
public static IServiceCollection AddApiServices(this IServiceCollection services)
{
// Add API-specific services
services.AddControllers();
services.AddEndpointsApiExplorer();
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Title = "Cleanuperr API",
Version = "v1",
Description = "API for managing media downloads and cleanups",
Contact = new OpenApiContact
{
Name = "Cleanuperr Team"
}
});
});
return services;
}
public static WebApplication ConfigureApi(this WebApplication app)
{
// Configure middleware pipeline for API
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Cleanuperr API v1");
options.RoutePrefix = "swagger";
options.DocumentTitle = "Cleanuperr API Documentation";
});
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
return app;
}
}

View File

@@ -1,4 +1,4 @@
using Common.Configuration.ContentBlocker;
using Common.Configuration.ContentBlocker;
using Common.Configuration.DownloadCleaner;
using Common.Configuration.QueueCleaner;
using Infrastructure.Interceptors;
@@ -16,6 +16,7 @@ using Infrastructure.Verticals.DownloadRemover.Interfaces;
using Infrastructure.Verticals.Files;
using Infrastructure.Verticals.ItemStriker;
using Infrastructure.Verticals.QueueCleaner;
using Infrastructure.Services;
namespace Executable.DependencyInjection;
@@ -23,6 +24,10 @@ public static class ServicesDI
{
public static IServiceCollection AddServices(this IServiceCollection services) =>
services
// API services
.AddSingleton<IJobManagementService, JobManagementService>()
.AddSingleton<IConfigurationService, ConfigurationService>()
// Core services
.AddTransient<IDryRunInterceptor, DryRunInterceptor>()
.AddTransient<CertificateValidationService>()
.AddTransient<SonarrClient>()