Spaces:
Runtime error
Runtime error
Download src/app/api/queue/publish/route.ts from damndeepesh-dev/RippleWorkers: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/damndeepesh-dev/RippleWorkers/resolve/main/src/app/api/queue/publish/route.ts
- Command line
-
hf download hf://spaces/damndeepesh-dev/RippleWorkers/src/app/api/queue/publish/route.ts
-
curl -L -o route.ts https://huggingface.co/spaces/damndeepesh-dev/RippleWorkers/resolve/main/src/app/api/queue/publish/route.ts
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); | |