Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/recoup/scrapeSocial.ts
Original file line number Diff line number Diff line change
@@ -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(),
Expand All @@ -9,8 +10,6 @@ const scrapeResponseSchema = z.object({

export type ScrapeSocialResponse = z.infer<typeof scrapeResponseSchema>;

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.
Expand All @@ -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) {
Expand Down
Loading