27 lines
841 B
TypeScript
27 lines
841 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import { resumeTorrent } from '@/lib/qbittorrent';
|
|
import { QbittorrentResumeResponse } from '@/types';
|
|
|
|
export async function POST(request: Request) {
|
|
try {
|
|
const { hash } = await request.json();
|
|
|
|
if (!hash) {
|
|
return NextResponse.json({ error: 'Hash is required' }, { status: 400 });
|
|
}
|
|
|
|
await resumeTorrent(hash);
|
|
|
|
const response: QbittorrentResumeResponse = { success: true };
|
|
return NextResponse.json(response);
|
|
|
|
} catch (error) {
|
|
console.error('Error resuming torrent:', error);
|
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
return NextResponse.json({
|
|
error: 'Failed to resume torrent',
|
|
details: errorMessage
|
|
}, { status: 500 });
|
|
}
|
|
}
|