/**
 * DEPRECATED: Legacy synchronous extraction endpoint
 * 
 * This endpoint is deprecated and will be removed in a future version.
 * Use the new async queue system instead:
 * 
 * POST /api/queue - Submit URL for async processing
 * GET /api/queue/stream - Real-time progress updates via SSE
 * 
 * Migration Guide: /docs/MIGRATION.md
 */

import { json } from '@sveltejs/kit';
import type { RequestHandler } from './$types.js';

export const POST: RequestHandler = async ({ request }) => {
	const { url } = await request.json();

	console.warn('[DEPRECATED] /api/extract endpoint called - use /api/queue instead');
	console.warn('URL attempted:', url);

	return json(
		{
			error: 'Endpoint deprecated',
			message: 'This endpoint is deprecated. Use the new async queue system.',
			migration: {
				newEndpoint: 'POST /api/queue',
				progressUpdates: 'GET /api/queue/stream',
				documentation: '/docs/MIGRATION.md',
				breakingChange: true,
				removedIn: 'v2.0.0'
			}
		},
		{ 
			status: 410, // 410 Gone - resource no longer available
			headers: {
				'X-Deprecated': 'true',
				'X-Migration-Guide': '/docs/MIGRATION.md',
				'X-New-Endpoint': '/api/queue'
			}
		}
	);
};