dvijaykrishnan's picture
Add manual trigger endpoint for product detection
25cb43e
Raw
History Blame Contribute Delete
1.1 kB
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()
});
}