mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-03 04:40:09 +00:00
4b90b35748
Extend multi-download-client support to include Transmission and NZBGet and introduce per-client custom download paths. Adds protocol mapping and new client types, Transmission/NZBGet integration services, API CRUD and validation changes, UI components/modal updates and live path previews, and manager routing by protocol. Includes DB migrations (download_path on download_history, interactive_search_access on users), schema updates, and related processor/service fixes and tests to ensure backward compatibility and proper path resolution.
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
/**
|
|
* Component: Setup Wizard Test Prowlarr API
|
|
* Documentation: documentation/setup-wizard.md
|
|
*/
|
|
|
|
import { NextRequest, NextResponse } from 'next/server';
|
|
import { ProwlarrService } from '@/lib/integrations/prowlarr.service';
|
|
import { requireSetupIncomplete } from '@/lib/middleware/auth';
|
|
import { RMABLogger } from '@/lib/utils/logger';
|
|
|
|
const logger = RMABLogger.create('API.Setup.TestProwlarr');
|
|
|
|
export async function POST(request: NextRequest) {
|
|
return requireSetupIncomplete(request, async (req) => {
|
|
try {
|
|
const { url, apiKey } = await req.json();
|
|
|
|
if (!url || !apiKey) {
|
|
return NextResponse.json(
|
|
{ success: false, error: 'URL and API key are required' },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
// Create a new ProwlarrService instance with test credentials
|
|
const prowlarrService = new ProwlarrService(url, apiKey);
|
|
|
|
// Test connection and get indexers
|
|
const indexers = await prowlarrService.getIndexers();
|
|
|
|
// Only return enabled indexers
|
|
const enabledIndexers = indexers.filter((indexer) => indexer.enable);
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
indexerCount: enabledIndexers.length,
|
|
totalIndexers: indexers.length,
|
|
indexers: enabledIndexers.map((indexer) => ({
|
|
id: indexer.id,
|
|
name: indexer.name,
|
|
protocol: indexer.protocol,
|
|
supportsRss: indexer.capabilities?.supportsRss !== false, // Default to true if not specified
|
|
})),
|
|
});
|
|
} catch (error) {
|
|
logger.error('Prowlarr test failed', { error: error instanceof Error ? error.message : String(error) });
|
|
return NextResponse.json(
|
|
{
|
|
success: false,
|
|
error: error instanceof Error ? error.message : 'Failed to connect to Prowlarr',
|
|
},
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
});
|
|
}
|