import { NextResponse } from 'next/server' export async function POST(request) { try { const { symbol, timeframe } = await request.json(); console.log('📊 Capturing REAL TradingView chart for:', symbol, timeframe); // Use the REAL TradingView automation service const tradingViewAutomation = require('../../../lib/tradingview-automation'); const result = await tradingViewAutomation.captureChart({ symbol, timeframe, layouts: ['ai', 'diy'] }); if (!result.success) { throw new Error(result.error || 'TradingView capture failed'); } console.log('📊 REAL TradingView chart captured'); return NextResponse.json({ success: true, screenshots: result.screenshots, sessionData: result.sessionData, source: 'REAL_TRADINGVIEW_AUTOMATION' }); } catch (error) { console.error('Error capturing TradingView chart:', error); return NextResponse.json({ success: false, error: error.message }, { status: 500 }); } } export async function GET() { return NextResponse.json({ message: 'TradingView Chart API - Use POST to capture charts', supportedLayouts: ['ai', 'Diy module'], supportedTimeframes: ['1', '5', '15', '60', '240', 'D', 'W'], requiredFields: ['symbol', 'timeframe'] }) }