From 7ac82aee203aa1cca3eb096847e2ae9faa800c10 Mon Sep 17 00:00:00 2001 From: Arpit Gupta Date: Tue, 21 Apr 2026 01:41:21 +0530 Subject: [PATCH] feat: cut scrapeSocial caller to /api/socials/{id}/scrape with x-api-key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Repoint URL from https://api.recoupable.com/api/social/scrape to `${NEW_API_BASE_URL}/api/socials/${socialId}/scrape` (nested RESTful path). - Send `x-api-key: RECOUP_API_KEY` auth header; guard undefined key. - Drop `social_id` from request body (id now lives in the path). Response schema `{ runId, datasetId }` unchanged — parity holds with the mono-hosted handler at `api/lib/socials/postSocialScrapeHandler.ts`. --- src/recoup/scrapeSocial.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/recoup/scrapeSocial.ts b/src/recoup/scrapeSocial.ts index e1670af..133bbab 100644 --- a/src/recoup/scrapeSocial.ts +++ b/src/recoup/scrapeSocial.ts @@ -1,5 +1,6 @@ import { logger } from "@trigger.dev/sdk/v3"; import { z } from "zod"; +import { NEW_API_BASE_URL, RECOUP_API_KEY } from "../consts"; const scrapeResponseSchema = z.object({ runId: z.string().nullable(), @@ -9,8 +10,6 @@ const scrapeResponseSchema = z.object({ export type ScrapeSocialResponse = z.infer; -const SOCIAL_SCRAPE_API_URL = "https://api.recoupable.com/api/social/scrape"; - /** * Triggers a social profile scraping job for a given social_id. * Returns Apify run metadata that can be used to poll for status and retrieve results. @@ -23,15 +22,21 @@ export async function scrapeSocial( return undefined; } + if (!RECOUP_API_KEY) { + logger.error("RECOUP_API_KEY not configured"); + return undefined; + } + + const url = `${NEW_API_BASE_URL}/api/socials/${socialId}/scrape`; + try { - const response = await fetch(SOCIAL_SCRAPE_API_URL, { + const response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json", + "x-api-key": RECOUP_API_KEY, }, - body: JSON.stringify({ - social_id: socialId, - }), + body: JSON.stringify({}), }); if (!response.ok) {