Spaces:
Runtime error
Runtime error
File size: 1,129 Bytes
c7fbc2e | 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 | import { NextRequest, NextResponse } from "next/server";
import { verifySignatureAppRouter } from "@upstash/qstash/dist/nextjs";
import { publishPost } from "@/lib/instagram-publisher";
async function handler(req: NextRequest) {
const body = await req.json();
const { postId } = body;
if (!postId) {
return NextResponse.json({ error: "postId is required" }, { status: 400 });
}
console.log(`Queue Worker: Received job for post ${postId}`);
try {
await publishPost(postId);
return NextResponse.json({ success: true });
} catch (error: any) {
console.error(`Queue Worker Failed for ${postId}:`, error);
return NextResponse.json({ error: error.message }, { status: 500 });
}
}
// Disable signature verification in development for easier testing if needed,
// but strictly speaking we should enable it.
// To use verifySignatureAppRouter, we need QSTASH_CURRENT_SIGNING_KEY in env.
// For now, let's keep it simple and assume the user adds the key, or we skip verification if not present (dev mode).
export const POST = verifySignatureAppRouter(handler);
|