File size: 1,096 Bytes
25cb43e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { NextRequest, NextResponse } from 'next/server';

// Import our server logic
import { inngest } from '@/inngest/client';

export async function POST(req: NextRequest) {
  try {
    const body = await req.json();
    
    console.log('Manual trigger endpoint hit with data:', body);
    
    // Create an event object that matches the expected format
    const event = {
      name: 'youtube/video.detect-objects',
      data: body
    };
    
    // Send event directly to Inngest to trigger the function
    const result = await inngest.send(event);
    
    return NextResponse.json({ success: true, result });
  } catch (error) {
    console.error('Manual trigger error:', error);
    return NextResponse.json(
      { success: false, error: error instanceof Error ? error.message : 'Unknown error' },
      { status: 500 }
    );
  }
}

// Add a simple GET endpoint to test connectivity
export async function GET() {
  return NextResponse.json({ 
    status: 'trigger-endpoint-ok', 
    message: 'Manual trigger endpoint is available',
    timestamp: new Date().toISOString()
  });
}