damndeepesh
Initialize project with LavinMQ integration and Docker support
c7fbc2e
Raw History Blame Contribute Delete
1.13 kB
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);