mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
- Register DeezerDownloadService and DeezerMetadataService as Singleton to properly share state across requests (rate limiting, download tracking) - Fix race condition in LocalLibraryService.LoadMappingsAsync with double-check locking pattern - Dispose HttpRequestMessage objects to prevent memory leaks (4 occurrences) - Handle fire-and-forget TriggerLibraryScanAsync with proper error logging - Replace Console.WriteLine with ILogger in SubsonicController - Fix while loop in DownloadSongAsync to refresh activeDownload state - Use modern C# range operator syntax for Substring calls - Clean up appsettings.json template (remove private IP, clear ARL token) - Add documentation comment for Blowfish decryption key - Add downloads directory to gitignore
51 lines
1.3 KiB
C#
51 lines
1.3 KiB
C#
using octo_fiesta.Models;
|
|
using octo_fiesta.Services;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddControllers();
|
|
builder.Services.AddHttpClient();
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
// Configuration
|
|
builder.Services.Configure<SubsonicSettings>(
|
|
builder.Configuration.GetSection("Subsonic"));
|
|
|
|
// Business services
|
|
// Registered as Singleton to share state (mappings cache, scan debounce, download tracking, rate limiting)
|
|
builder.Services.AddSingleton<ILocalLibraryService, LocalLibraryService>();
|
|
builder.Services.AddSingleton<IMusicMetadataService, DeezerMetadataService>();
|
|
builder.Services.AddSingleton<IDownloadService, DeezerDownloadService>();
|
|
|
|
builder.Services.AddCors(options =>
|
|
{
|
|
options.AddDefaultPolicy(policy =>
|
|
{
|
|
policy.AllowAnyOrigin()
|
|
.AllowAnyMethod()
|
|
.AllowAnyHeader()
|
|
.WithExposedHeaders("X-Content-Duration", "X-Total-Count", "X-Nd-Authorization");
|
|
});
|
|
});
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.UseCors();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run(); |